summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-11-26 01:07:49 +0000
committerrubidium <rubidium@openttd.org>2008-11-26 01:07:49 +0000
commitb0a9ce2d9a71e5d53e78ccaac3fae5bf79f76a91 (patch)
tree8022d37179ec08ca7defea8941abd3e126b1f985
parentc7a052200d9a33e235ed680f860b0213448dd71f (diff)
downloadopenttd-b0a9ce2d9a71e5d53e78ccaac3fae5bf79f76a91.tar.xz
(svn r14635) -Change: use S_ISDIR/S_ISREG as x & S_IFREG always results false on platforms when S_IFREG is 0x0000.
-rw-r--r--src/fileio.cpp4
-rw-r--r--src/stdafx.h5
2 files changed, 7 insertions, 2 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index a4ba69cc2..f7b4a5af2 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -984,12 +984,12 @@ static uint ScanPath(FileScanner *fs, const char *extension, const char *path, s
snprintf(filename, lengthof(filename), "%s%s", path, d_name);
- if (sb.st_mode & S_IFDIR) {
+ if (S_ISDIR(sb.st_mode)) {
/* Directory */
if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue;
AppendPathSeparator(filename, lengthof(filename));
num += ScanPath(fs, extension, filename, basepath_length);
- } else if (sb.st_mode & S_IFREG) {
+ } else if (S_ISREG(sb.st_mode)) {
/* File */
char *ext = strrchr(filename, '.');
diff --git a/src/stdafx.h b/src/stdafx.h
index 34da8f501..a0d715ed3 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -235,6 +235,11 @@
#undef assert
#define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
#endif
+
+ /* MSVC doesn't have these :( */
+ #define S_ISDIR(mode) (mode & S_IFDIR)
+ #define S_ISREG(mode) (mode & S_IFREG)
+
#endif /* defined(_MSC_VER) */
#if defined(WINCE)