224 if (mode != SLD_NEW_GAME && (dir = ttd_opendir(_fios_path)) != NULL) { |
224 if (mode != SLD_NEW_GAME && (dir = ttd_opendir(_fios_path)) != NULL) { |
225 while ((dirent = readdir(dir)) != NULL) { |
225 while ((dirent = readdir(dir)) != NULL) { |
226 strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name)); |
226 strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name)); |
227 |
227 |
228 /* found file must be directory, but not '.' or '..' */ |
228 /* found file must be directory, but not '.' or '..' */ |
229 if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) && |
229 if (FiosIsValidFile(_fios_path, dirent, &sb) && S_ISDIR(sb.st_mode) && |
230 (!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) && |
230 (!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) && |
231 strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { |
231 strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { |
232 fios = _fios_items.Append(); |
232 fios = _fios_items.Append(); |
233 fios->type = FIOS_TYPE_DIR; |
233 fios->type = FIOS_TYPE_DIR; |
234 fios->mtime = 0; |
234 fios->mtime = 0; |
257 while ((dirent = readdir(dir)) != NULL) { |
257 while ((dirent = readdir(dir)) != NULL) { |
258 char fios_title[64]; |
258 char fios_title[64]; |
259 char *t; |
259 char *t; |
260 strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name)); |
260 strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name)); |
261 |
261 |
262 if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG) || FiosIsHiddenFile(dirent)) continue; |
262 if (!FiosIsValidFile(_fios_path, dirent, &sb) || !S_ISREG(sb.st_mode) || FiosIsHiddenFile(dirent)) continue; |
263 |
263 |
264 /* File has no extension, skip it */ |
264 /* File has no extension, skip it */ |
265 if ((t = strrchr(d_name, '.')) == NULL) continue; |
265 if ((t = strrchr(d_name, '.')) == NULL) continue; |
266 fios_title[0] = '\0'; // reset the title; |
266 fios_title[0] = '\0'; // reset the title; |
267 |
267 |