mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r14656) -Change: replace instances of x & S_IFREG with S_ISREG(x) as S_IFREG can be 0 on some platforms.
This commit is contained in:
parent
1b91ec49c8
commit
bcb9a11754
|
@ -711,12 +711,12 @@ static int ScanPathForTarFiles(const char *path, size_t basepath_length)
|
||||||
|
|
||||||
snprintf(filename, lengthof(filename), "%s%s", path, d_name);
|
snprintf(filename, lengthof(filename), "%s%s", path, d_name);
|
||||||
|
|
||||||
if (sb.st_mode & S_IFDIR) {
|
if (S_ISDIR(sb.st_mode)) {
|
||||||
/* Directory */
|
/* Directory */
|
||||||
if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue;
|
if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue;
|
||||||
AppendPathSeparator(filename, lengthof(filename));
|
AppendPathSeparator(filename, lengthof(filename));
|
||||||
num += ScanPathForTarFiles(filename, basepath_length);
|
num += ScanPathForTarFiles(filename, basepath_length);
|
||||||
} else if (sb.st_mode & S_IFREG) {
|
} else if (S_ISREG(sb.st_mode)) {
|
||||||
/* File */
|
/* File */
|
||||||
char *ext = strrchr(filename, '.');
|
char *ext = strrchr(filename, '.');
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
|
||||||
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
|
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
|
||||||
|
|
||||||
/* found file must be directory, but not '.' or '..' */
|
/* found file must be directory, but not '.' or '..' */
|
||||||
if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) &&
|
if (FiosIsValidFile(_fios_path, dirent, &sb) && S_ISDIR(sb.st_mode) &&
|
||||||
(!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) &&
|
(!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) &&
|
||||||
strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) {
|
strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) {
|
||||||
fios = _fios_items.Append();
|
fios = _fios_items.Append();
|
||||||
|
@ -259,7 +259,7 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
|
||||||
char *t;
|
char *t;
|
||||||
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
|
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
|
||||||
|
|
||||||
if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG) || FiosIsHiddenFile(dirent)) continue;
|
if (!FiosIsValidFile(_fios_path, dirent, &sb) || !S_ISREG(sb.st_mode) || FiosIsHiddenFile(dirent)) continue;
|
||||||
|
|
||||||
/* File has no extension, skip it */
|
/* File has no extension, skip it */
|
||||||
if ((t = strrchr(d_name, '.')) == NULL) continue;
|
if ((t = strrchr(d_name, '.')) == NULL) continue;
|
||||||
|
|
Loading…
Reference in New Issue