31 static int _fios_count, _fios_alloc; |
31 static int _fios_count, _fios_alloc; |
32 |
32 |
33 /* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */ |
33 /* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */ |
34 extern bool FiosIsRoot(const char *path); |
34 extern bool FiosIsRoot(const char *path); |
35 extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb); |
35 extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb); |
|
36 extern bool FiosIsHiddenFile(const struct dirent *ent); |
36 extern void FiosGetDrives(void); |
37 extern void FiosGetDrives(void); |
37 extern bool FiosGetDiskFreeSpace(const char *path, uint32 *tot); |
38 extern bool FiosGetDiskFreeSpace(const char *path, uint32 *tot); |
38 |
39 |
39 /* get the name of an oldstyle savegame */ |
40 /* get the name of an oldstyle savegame */ |
40 extern void GetOldSaveGameName(char *title, const char *path, const char *file); |
41 extern void GetOldSaveGameName(char *title, const char *path, const char *file); |
225 while ((dirent = readdir(dir)) != NULL) { |
226 while ((dirent = readdir(dir)) != NULL) { |
226 ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); |
227 ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); |
227 |
228 |
228 /* found file must be directory, but not '.' or '..' */ |
229 /* found file must be directory, but not '.' or '..' */ |
229 if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) && |
230 if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) && |
230 strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { |
231 (!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) && |
|
232 strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { |
231 fios = FiosAlloc(); |
233 fios = FiosAlloc(); |
232 fios->type = FIOS_TYPE_DIR; |
234 fios->type = FIOS_TYPE_DIR; |
233 fios->mtime = 0; |
235 fios->mtime = 0; |
234 ttd_strlcpy(fios->name, d_name, lengthof(fios->name)); |
236 ttd_strlcpy(fios->name, d_name, lengthof(fios->name)); |
235 snprintf(fios->title, lengthof(fios->title), "%s" PATHSEP " (Directory)", d_name); |
237 snprintf(fios->title, lengthof(fios->title), "%s" PATHSEP " (Directory)", d_name); |
256 while ((dirent = readdir(dir)) != NULL) { |
258 while ((dirent = readdir(dir)) != NULL) { |
257 char fios_title[64]; |
259 char fios_title[64]; |
258 char *t; |
260 char *t; |
259 ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); |
261 ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); |
260 |
262 |
261 if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG)) continue; |
263 if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG) || FiosIsHiddenFile(dirent)) continue; |
262 |
264 |
263 /* File has no extension, skip it */ |
265 /* File has no extension, skip it */ |
264 if ((t = strrchr(d_name, '.')) == NULL) continue; |
266 if ((t = strrchr(d_name, '.')) == NULL) continue; |
265 fios_title[0] = '\0'; // reset the title; |
267 fios_title[0] = '\0'; // reset the title; |
266 |
268 |