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 )
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
#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__
(st.st_mode == S_IFDIR);
#endif
-#endif
+#endif // __WIN32__/!__WIN32__
}
// Get a temporary filename, opening and closing the file.