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" 21 #include "../../thread.h" 23 #include "table/strings.h" 30 #ifndef __INNOTEK_LIBC__ 34 #include "../../safeguards.h" 37 #define INCL_WINCLIPBOARD 40 #ifndef __INNOTEK_LIBC__ 44 bool FiosIsRoot(
const char *file)
46 return file[3] ==
'\0';
49 void FiosGetDrives(
FileList &file_list)
51 uint disk, disk2, save, total;
53 #ifndef __INNOTEK_LIBC__ 63 #ifndef __INNOTEK_LIBC__ 64 for (disk = 1;; disk++) {
65 _dos_setdrive(disk, &total);
67 for (disk =
'A';; disk++) {
70 if (disk >= total)
break;
72 #ifndef __INNOTEK_LIBC__ 73 _dos_getdrive(&disk2);
80 fios->type = FIOS_TYPE_DRIVE;
82 #ifndef __INNOTEK_LIBC__ 83 snprintf(fios->name,
lengthof(fios->name),
"%c:",
'A' + disk - 1);
85 snprintf(fios->name,
lengthof(fios->name),
"%c:", disk);
92 #ifndef __INNOTEK_LIBC__ 93 _dos_setdrive(save, &total);
99 bool FiosGetDiskFreeSpace(
const char *path, uint64 *tot)
101 #ifndef __INNOTEK_LIBC__ 102 struct diskfree_t
free;
103 char drive = path[0] -
'A' + 1;
105 if (tot !=
nullptr && _getdiskfree(drive, &
free) == 0) {
106 *tot =
free.avail_clusters *
free.sectors_per_cluster *
free.bytes_per_sector;
118 if (statvfs(path, &s) != 0)
return false;
119 free = (uint64)s.f_frsize * s.f_bavail;
122 if (tot !=
nullptr) *tot =
free;
127 bool FiosIsValidFile(
const char *path,
const struct dirent *ent,
struct stat *sb)
129 char filename[MAX_PATH];
131 snprintf(filename,
lengthof(filename),
"%s" PATHSEP
"%s", path, ent->d_name);
132 return stat(filename, sb) == 0;
135 bool FiosIsHiddenFile(
const struct dirent *ent)
137 return ent->d_name[0] ==
'.';
140 void ShowInfo(
const char *str)
147 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
150 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)str, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
153 WinDestroyMsgQueue(hmq);
157 void ShowOSErrorBox(
const char *buf,
bool system)
164 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
167 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)buf, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
170 WinDestroyMsgQueue(hmq);
174 int CDECL
main(
int argc,
char *argv[])
187 #ifndef __INNOTEK_LIBC__ 190 if (WinOpenClipbrd(hab))
192 const char *text = (
const char*)WinQueryClipbrdData(hab, CF_TEXT);
197 WinCloseClipbrd(hab);
201 WinCloseClipbrd(hab);
208 const char *
FS2OTTD(
const char *name) {
return name;}
209 const char *
OTTD2FS(
const char *name) {
return name;}
211 void OSOpenBrowser(
const char *url)
214 DEBUG(misc, 0,
"Failed to open url: %s", url);
int openttd_main(int argc, char *argv[])
Main entry point for this lovely game.
const char * FS2OTTD(const TCHAR *name)
Convert to OpenTTD's encoding from that of the local environment.
bool GetClipboardContents(char *buffer, const char *last)
Try to retrieve the current clipboard contents.
void SetCurrentThreadName(const char *)
Name the thread this function is called on for the debugger.
void SetRandomSeed(uint32 seed)
(Re)set the state of the random number generators.
#define lastof(x)
Get the last element of an fixed size array.
Deals with finding savegames.
int main(int argc, char *argv[])
Entry point.
#define lengthof(x)
Return the length of an fixed size array.
const TCHAR * OTTD2FS(const char *name, bool console_cp)
Convert from OpenTTD's encoding to that of the local environment.
#define DEBUG(name, level,...)
Output a line of debugging information.
List of file information.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void ValidateString(const char *str)
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mar...
FiosItem * Append()
Construct a new entry in the file list.