X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/678c48b37d06743464a6fca756dc0ca056a796e9..93d2bf4406e5f850189f827275c66ef99bb64791:/src/common/filefn.cpp?ds=inline diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index fef89de43f..5b59a1baba 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -272,8 +272,11 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) bool wxFileExists (const wxString& filename) { -#ifdef __GNUWIN32__ // (fix a B20 bug) - return GetFileAttributes(filename) != 0xFFFFFFFF; +#ifdef __WINDOWS__ + // GetFileAttributes can copy with network paths + DWORD ret = GetFileAttributes(filename); + DWORD isDir = (ret & FILE_ATTRIBUTE_DIRECTORY); + return ((ret != 0xffffffff) && (isDir == 0)); #else wxStructStat stbuf; if ( !filename.empty() && wxStat (OS_FILENAME(filename), &stbuf) == 0 ) @@ -287,16 +290,16 @@ bool wxIsAbsolutePath (const wxString& filename) { #ifdef __WXMAC__ - if (filename != wxT("")) - { -// This seems wrong to me, RR. FIXME. + if (filename != wxT("")) + { + // This seems wrong to me, but there is no fix. since + // "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt" + // is not. Or maybe ":MyDir:MyText.txt" has to be used? RR. - if( filename.Find(':') != wxNOT_FOUND && filename[0] != ':' ) - return TRUE ; - -// if (filename[0] == ':') return TRUE ; - } - return FALSE ; + if (filename.Find(':') != wxNOT_FOUND && filename[0] != ':') + return TRUE ; + } + return FALSE ; #else if (filename != wxT("")) { @@ -1179,13 +1182,20 @@ bool wxPathExists(const wxChar *pszPathName) while ( wxEndsWithPathSeparator(strPath) ) { size_t len = strPath.length(); - if ( len == 1 || strPath[len - 1] == _T(':') ) + if ( len == 1 || (len == 3 && strPath[len - 2] == _T(':')) ) break; strPath.Truncate(len - 1); } #endif // __WINDOWS__ +#ifdef __WINDOWS__ + // Stat can't cope with network paths + DWORD ret = GetFileAttributes(strPath.c_str()); + DWORD isDir = (ret & FILE_ATTRIBUTE_DIRECTORY); + return ((ret != 0xffffffff) && (isDir != 0)); +#else + wxStructStat st; #ifndef __VISAGECPP__ return wxStat(wxFNSTRINGCAST strPath.fn_str(), &st) == 0 && @@ -1196,6 +1206,7 @@ bool wxPathExists(const wxChar *pszPathName) (st.st_mode == S_IFDIR); #endif +#endif } // Get a temporary filename, opening and closing the file.