X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2db300c6643131b51a3a6a10815cf74850db5e58..59c962bf54667cab735353b2ec3b7a2438464f22:/src/common/filefn.cpp diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index ba270dea90..583c0711b3 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -119,7 +119,9 @@ // // note that it must be included after #ifdef __GNUWIN32__ - #include + #ifdef __CYGWIN__ + #include + #endif #include #ifndef __TWIN32__ #include @@ -300,16 +302,10 @@ bool wxFileExists (const wxString& filename) { #if defined(__WIN32__) && !defined(__WXMICROWIN__) - // GetFileAttributes can copy with network paths + // GetFileAttributes can copy with network paths unlike stat() DWORD ret = ::GetFileAttributes(filename); - if ( ret == (DWORD)-1 ) - { - wxLogLastError(_T("GetFileAttributes")); - return FALSE; - } - - return !(ret & FILE_ATTRIBUTE_DIRECTORY); + return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY); #else wxStructStat stbuf; if ( !filename.empty() && wxStat (OS_FILENAME(filename), &stbuf) == 0 ) @@ -1266,6 +1262,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) bool wxPathExists(const wxChar *pszPathName) { wxString strPath(pszPathName); + #ifdef __WINDOWS__ // Windows fails to find directory named "c:\dir\" even if "c:\dir" exists, // so remove all trailing backslashes from the path - but don't do this for @@ -1281,17 +1278,11 @@ bool wxPathExists(const wxChar *pszPathName) #endif // __WINDOWS__ #if defined(__WIN32__) && !defined(__WXMICROWIN__) - // Stat can't cope with network paths - DWORD ret = ::GetFileAttributes(filename); - if ( ret == (DWORD)-1 ) - { - wxLogLastError(_T("GetFileAttributes")); - - return FALSE; - } + // stat() can't cope with network paths + DWORD ret = ::GetFileAttributes(strPath); - return (ret & FILE_ATTRIBUTE_DIRECTORY) != 0; -#else + return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY); +#else // !__WIN32__ wxStructStat st; #ifndef __VISAGECPP__ @@ -1303,7 +1294,7 @@ bool wxPathExists(const wxChar *pszPathName) (st.st_mode == S_IFDIR); #endif -#endif +#endif // __WIN32__/!__WIN32__ } // Get a temporary filename, opening and closing the file. @@ -1472,11 +1463,11 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) } #endif // __DJGPP__ -#ifdef __GNUWIN32__ +#ifdef __CYGWIN__ // another example of DOS/Unix mix (Cygwin) wxString pathUnix = buf; cygwin_conv_to_full_win32_path(pathUnix, buf); -#endif // __GNUWIN32__ +#endif // __CYGWIN__ // finally convert the result to Unicode if needed #if wxUSE_UNICODE && !defined(HAVE_WGETCWD)