10 #include "../../stdafx.h" 11 #include "../../openttd.h" 12 #include "../../gui.h" 13 #include "../../fileio_func.h" 14 #include "../../fios.h" 15 #include "../../openttd.h" 16 #include "../../core/random_func.hpp" 17 #include "../../string_func.h" 18 #include "../../textbuf_gui.h" 19 #include "../../thread.h" 21 #include "table/strings.h" 28 #ifndef __INNOTEK_LIBC__ 32 #include "../../safeguards.h" 35 #define INCL_WINCLIPBOARD 38 #ifndef __INNOTEK_LIBC__ 42 bool FiosIsRoot(
const char *file)
44 return file[3] ==
'\0';
47 void FiosGetDrives(
FileList &file_list)
49 uint disk, disk2, save, total;
51 #ifndef __INNOTEK_LIBC__ 61 #ifndef __INNOTEK_LIBC__ 62 for (disk = 1;; disk++) {
63 _dos_setdrive(disk, &total);
65 for (disk =
'A';; disk++) {
68 if (disk >= total)
break;
70 #ifndef __INNOTEK_LIBC__ 71 _dos_getdrive(&disk2);
78 fios->type = FIOS_TYPE_DRIVE;
80 #ifndef __INNOTEK_LIBC__ 81 snprintf(fios->name,
lengthof(fios->name),
"%c:",
'A' + disk - 1);
83 snprintf(fios->name,
lengthof(fios->name),
"%c:", disk);
90 #ifndef __INNOTEK_LIBC__ 91 _dos_setdrive(save, &total);
97 bool FiosGetDiskFreeSpace(
const char *path, uint64 *tot)
99 #ifndef __INNOTEK_LIBC__ 100 struct diskfree_t
free;
101 char drive = path[0] -
'A' + 1;
103 if (tot !=
nullptr && _getdiskfree(drive, &
free) == 0) {
104 *tot =
free.avail_clusters *
free.sectors_per_cluster *
free.bytes_per_sector;
116 if (statvfs(path, &s) != 0)
return false;
117 free = (uint64)s.f_frsize * s.f_bavail;
120 if (tot !=
nullptr) *tot =
free;
125 bool FiosIsValidFile(
const char *path,
const struct dirent *ent,
struct stat *sb)
127 char filename[MAX_PATH];
129 snprintf(filename,
lengthof(filename),
"%s" PATHSEP
"%s", path, ent->d_name);
130 return stat(filename, sb) == 0;
133 bool FiosIsHiddenFile(
const struct dirent *ent)
135 return ent->d_name[0] ==
'.';
138 void ShowInfo(
const char *str)
145 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
148 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)str, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION);
151 WinDestroyMsgQueue(hmq);
155 void ShowOSErrorBox(
const char *buf,
bool system)
162 hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0);
165 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (
const unsigned char *)buf, (
const unsigned char *)
"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR);
168 WinDestroyMsgQueue(hmq);
172 int CDECL
main(
int argc,
char *argv[])
185 #ifndef __INNOTEK_LIBC__ 188 if (WinOpenClipbrd(hab))
190 const char *text = (
const char*)WinQueryClipbrdData(hab, CF_TEXT);
195 WinCloseClipbrd(hab);
199 WinCloseClipbrd(hab);
206 const char *
FS2OTTD(
const char *name) {
return name;}
207 const char *
OTTD2FS(
const char *name) {
return name;}
209 void OSOpenBrowser(
const char *url)
212 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.