12 #include "../../stdafx.h"
13 #include "../../openttd.h"
14 #include "../../gui.h"
15 #include "../../fileio_func.h"
16 #include "../../fios.h"
17 #include "../../openttd.h"
18 #include "../../core/random_func.hpp"
19 #include "../../string_func.h"
20 #include "../../textbuf_gui.h"
22 #include "table/strings.h"
29 #ifndef __INNOTEK_LIBC__
33 #include "../../safeguards.h"
36 #define INCL_WINCLIPBOARD
39 #ifndef __INNOTEK_LIBC__
43 bool FiosIsRoot(
const char *file)
45 return file[3] ==
'\0';
50 uint disk, disk2, save, total;
52 #ifndef __INNOTEK_LIBC__
62 #ifndef __INNOTEK_LIBC__
63 for (disk = 1;; disk++) {
64 _dos_setdrive(disk, &total);
66 for (disk =
'A';; disk++) {
69 if (disk >= total)
break;
71 #ifndef __INNOTEK_LIBC__
72 _dos_getdrive(&disk2);
78 FiosItem *fios = _fios_items.Append();
79 fios->type = FIOS_TYPE_DRIVE;
81 #ifndef __INNOTEK_LIBC__
82 snprintf(fios->name,
lengthof(fios->name),
"%c:",
'A' + disk - 1);
84 snprintf(fios->name,
lengthof(fios->name),
"%c:", disk);
91 #ifndef __INNOTEK_LIBC__
92 _dos_setdrive(save, &total);
98 bool FiosGetDiskFreeSpace(
const char *path, uint64 *tot)
100 #ifndef __INNOTEK_LIBC__
101 struct diskfree_t
free;
102 char drive = path[0] -
'A' + 1;
104 if (tot != NULL && _getdiskfree(drive, &
free) == 0) {
105 *tot =
free.avail_clusters *
free.sectors_per_cluster *
free.bytes_per_sector;
117 if (statvfs(path, &s) != 0)
return false;
118 free = (uint64)s.f_frsize * s.f_bavail;
121 if (tot != NULL) *tot =
free;
126 bool FiosIsValidFile(
const char *path,
const struct dirent *ent,
struct stat *sb)
128 char filename[MAX_PATH];
130 snprintf(filename,
lengthof(filename),
"%s" PATHSEP
"%s", path, ent->d_name);
131 return stat(filename, sb) == 0;
134 bool FiosIsHiddenFile(
const struct dirent *ent)
136 return ent->d_name[0] ==
'.';
139 void ShowInfo(
const char *str)
146 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
149 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)str, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
152 WinDestroyMsgQueue(hmq);
156 void ShowOSErrorBox(
const char *buf,
bool system)
163 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
166 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)buf, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
169 WinDestroyMsgQueue(hmq);
173 int CDECL
main(
int argc,
char *argv[])
186 #ifndef __INNOTEK_LIBC__
189 if (WinOpenClipbrd(hab))
191 const char *text = (
const char*)WinQueryClipbrdData(hab, CF_TEXT);
196 WinCloseClipbrd(hab);
200 WinCloseClipbrd(hab);
207 void CSleep(
int milliseconds)
209 #ifndef __INNOTEK_LIBC__
212 usleep(milliseconds * 1000);
216 const char *
FS2OTTD(
const char *name) {
return name;}
217 const char *
OTTD2FS(
const char *name) {
return name;}
224 void OSOpenBrowser(
const char *url)
227 DEBUG(misc, 0,
"Failed to open url: %s", url);