src/fios.h
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6505 abcb0580d976
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
     4 
     4 
     5 #ifndef FIOS_H
     5 #ifndef FIOS_H
     6 #define FIOS_H
     6 #define FIOS_H
     7 
     7 
     8 /* Deals with finding savegames */
     8 /* Deals with finding savegames */
     9 typedef struct {
     9 struct FiosItem {
    10 	byte type;
    10 	byte type;
    11 	uint64 mtime;
    11 	uint64 mtime;
    12 	char title[64];
    12 	char title[64];
    13 	char name[256 - 12 - 64];
    13 	char name[256 - 12 - 64];
    14 } FiosItem;
    14 };
    15 
    15 
    16 enum {
    16 enum {
    17 	FIOS_TYPE_DRIVE        =   0,
    17 	FIOS_TYPE_DRIVE        =   0,
    18 	FIOS_TYPE_PARENT       =   1,
    18 	FIOS_TYPE_PARENT       =   1,
    19 	FIOS_TYPE_DIR          =   2,
    19 	FIOS_TYPE_DIR          =   2,
    37 /* Get a list of scenarios */
    37 /* Get a list of scenarios */
    38 FiosItem *FiosGetScenarioList(int mode);
    38 FiosItem *FiosGetScenarioList(int mode);
    39 /* Get a list of Heightmaps */
    39 /* Get a list of Heightmaps */
    40 FiosItem *FiosGetHeightmapList(int mode);
    40 FiosItem *FiosGetHeightmapList(int mode);
    41 /* Free the list of savegames */
    41 /* Free the list of savegames */
    42 void FiosFreeSavegameList(void);
    42 void FiosFreeSavegameList();
    43 /* Browse to. Returns a filename w/path if we reached a file. */
    43 /* Browse to. Returns a filename w/path if we reached a file. */
    44 char *FiosBrowseTo(const FiosItem *item);
    44 char *FiosBrowseTo(const FiosItem *item);
    45 /* Return path, free space and stringID */
    45 /* Return path, free space and stringID */
    46 StringID FiosGetDescText(const char **path, uint32 *total_free);
    46 StringID FiosGetDescText(const char **path, uint32 *total_free);
    47 /* Delete a name */
    47 /* Delete a name */
    48 bool FiosDelete(const char *name);
    48 bool FiosDelete(const char *name);
    49 /* Make a filename from a name */
    49 /* Make a filename from a name */
    50 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
    50 void FiosMakeSavegameName(char *buf, const char *name, size_t size);
    51 /* Allocate a new FiosItem */
    51 /* Allocate a new FiosItem */
    52 FiosItem *FiosAlloc(void);
    52 FiosItem *FiosAlloc();
    53 
    53 
    54 int CDECL compare_FiosItems(const void *a, const void *b);
    54 int CDECL compare_FiosItems(const void *a, const void *b);
    55 
    55 
    56 /* Implementation of opendir/readdir/closedir for Windows */
    56 /* Implementation of opendir/readdir/closedir for Windows */
    57 #if defined(WIN32)
    57 #if defined(WIN32)
    58 #include <windows.h>
    58 #include <windows.h>
    59 typedef struct DIR DIR;
    59 struct DIR;
    60 
    60 
    61 typedef struct dirent { // XXX - only d_name implemented
    61 struct dirent { // XXX - only d_name implemented
    62 	wchar_t *d_name; // name of found file
    62 	TCHAR *d_name; // name of found file
    63 	/* little hack which will point to parent DIR struct which will
    63 	/* little hack which will point to parent DIR struct which will
    64 	 * save us a call to GetFileAttributes if we want information
    64 	 * save us a call to GetFileAttributes if we want information
    65 	 * about the file (for example in function fio_bla) */
    65 	 * about the file (for example in function fio_bla) */
    66 	DIR *dir;
    66 	DIR *dir;
    67 } dirent;
    67 };
    68 
    68 
    69 struct DIR {
    69 struct DIR {
    70 	HANDLE hFind;
    70 	HANDLE hFind;
    71 	/* the dirent returned by readdir.
    71 	/* the dirent returned by readdir.
    72 	 * note: having only one global instance is not possible because
    72 	 * note: having only one global instance is not possible because
    73 	 * multiple independent opendir/readdir sequences must be supported. */
    73 	 * multiple independent opendir/readdir sequences must be supported. */
    74 	dirent ent;
    74 	dirent ent;
    75 	WIN32_FIND_DATAW fd;
    75 	WIN32_FIND_DATA fd;
    76 	/* since opendir calls FindFirstFile, we need a means of telling the
    76 	/* since opendir calls FindFirstFile, we need a means of telling the
    77 	 * first call to readdir that we already have a file.
    77 	 * first call to readdir that we already have a file.
    78 	 * that's the case iff this is true */
    78 	 * that's the case iff this is true */
    79 	bool at_first_entry;
    79 	bool at_first_entry;
    80 };
    80 };
    81 
    81 
    82 DIR *opendir(const wchar_t *path);
    82 DIR *opendir(const TCHAR *path);
    83 struct dirent *readdir(DIR *d);
    83 struct dirent *readdir(DIR *d);
    84 int closedir(DIR *d);
    84 int closedir(DIR *d);
    85 #else
    85 #else
    86 /* Use system-supplied opendir/readdir/closedir functions */
    86 /* Use system-supplied opendir/readdir/closedir functions */
    87 # include <sys/types.h>
    87 # include <sys/types.h>