]> git.saurik.com Git - wxWidgets.git/commitdiff
Use the posix S_ISREG instead of S_IFREG if it is defined. Fixes wxFileExists
authorMichael Wetherell <mike.wetherell@ntlworld.com>
Sun, 28 May 2006 18:58:12 +0000 (18:58 +0000)
committerMichael Wetherell <mike.wetherell@ntlworld.com>
Sun, 28 May 2006 18:58:12 +0000 (18:58 +0000)
on DJGPP where S_IFREG is defined as 0.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/filefn.cpp

index 3bd9d7c1bb524a9d75a546c3d8092f844292c74b..dec3887eb36b35d8492cdf6eaf5c36fe1cbb1131 100644 (file)
@@ -299,16 +299,19 @@ wxFileExists (const wxString& filename)
 
     return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
 #else // !__WIN32__
+    #ifndef S_ISREG
+        #define S_ISREG(mode) ((mode) & S_IFREG)
+    #endif
     wxStructStat st;
 #ifndef wxNEED_WX_UNISTD_H
-    return (wxStat( filename.fn_str() , &st) == 0 && (st.st_mode & S_IFREG))
+    return (wxStat( filename.fn_str() , &st) == 0 && S_ISREG(st.st_mode))
 #ifdef __OS2__
       || (errno == EACCES) // if access is denied something with that name
                             // exists and is opened in exclusive mode.
 #endif
       ;
 #else
-    return wxStat( filename , &st) == 0 && (st.st_mode & S_IFREG);
+    return wxStat( filename , &st) == 0 && S_ISREG(st.st_mode);
 #endif
 #endif // __WIN32__/!__WIN32__
 }