108 /* Determines type of savegame (or tells it is not a savegame) */ |
108 /* Determines type of savegame (or tells it is not a savegame) */ |
109 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title); |
109 FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title); |
110 |
110 |
111 int CDECL compare_FiosItems(const void *a, const void *b); |
111 int CDECL compare_FiosItems(const void *a, const void *b); |
112 |
112 |
113 /* Implementation of opendir/readdir/closedir for Windows */ |
|
114 #if defined(WIN32) |
|
115 #include <windows.h> |
|
116 struct DIR; |
|
117 |
|
118 struct dirent { // XXX - only d_name implemented |
|
119 TCHAR *d_name; // name of found file |
|
120 /* little hack which will point to parent DIR struct which will |
|
121 * save us a call to GetFileAttributes if we want information |
|
122 * about the file (for example in function fio_bla) */ |
|
123 DIR *dir; |
|
124 }; |
|
125 |
|
126 struct DIR { |
|
127 HANDLE hFind; |
|
128 /* the dirent returned by readdir. |
|
129 * note: having only one global instance is not possible because |
|
130 * multiple independent opendir/readdir sequences must be supported. */ |
|
131 dirent ent; |
|
132 WIN32_FIND_DATA fd; |
|
133 /* since opendir calls FindFirstFile, we need a means of telling the |
|
134 * first call to readdir that we already have a file. |
|
135 * that's the case iff this is true */ |
|
136 bool at_first_entry; |
|
137 }; |
|
138 |
|
139 DIR *opendir(const TCHAR *path); |
|
140 struct dirent *readdir(DIR *d); |
|
141 int closedir(DIR *d); |
|
142 #else |
|
143 /* Use system-supplied opendir/readdir/closedir functions */ |
|
144 # include <sys/types.h> |
|
145 # include <dirent.h> |
|
146 #endif /* defined(WIN32) */ |
|
147 |
|
148 /** |
|
149 * A wrapper around opendir() which will convert the string from |
|
150 * OPENTTD encoding to that of the filesystem. For all purposes this |
|
151 * function behaves the same as the original opendir function |
|
152 * @param path string to open directory of |
|
153 * @return DIR pointer |
|
154 */ |
|
155 static inline DIR *ttd_opendir(const char *path) |
|
156 { |
|
157 return opendir(OTTD2FS(path)); |
|
158 } |
|
159 |
|
160 #endif /* FIOS_H */ |
113 #endif /* FIOS_H */ |