X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd378f94bec1edc0f991ee55b02bfe3084de94e0..93d2bf4406e5f850189f827275c66ef99bb64791:/src/common/filefn.cpp

diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp
index 888fabd96c..5b59a1baba 100644
--- a/src/common/filefn.cpp
+++ b/src/common/filefn.cpp
@@ -78,6 +78,7 @@
 #endif // native Win compiler
 
 #ifdef __GNUWIN32__
+    #include <wchar.h>
     #ifndef __TWIN32__
         #include <sys/unistd.h>
     #endif
@@ -271,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 )
@@ -286,12 +290,16 @@ bool
 wxIsAbsolutePath (const wxString& filename)
 {
 #ifdef __WXMAC__
-  if (filename != wxT(""))
-  {
-    if( filename.Find(':') != wxNOT_FOUND && filename[0] != ':' )
-      return TRUE ;
-  }
-  return FALSE ;
+    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 ;
+    }
+    return FALSE ;
 #else
   if (filename != wxT(""))
     {
@@ -845,7 +853,6 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
     FSpLocationFromFullPath( strlen(path ) , path , spec ) ;
 }
 
-/*
 static char sMacFileNameConversion[ 1000 ] ;
 
 wxString wxMac2UnixFilename (const char *str)
@@ -917,17 +924,12 @@ wxString wxMacFSSpec2UnixFilename( const FSSpec *spec )
     return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
 }
 
-void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
-{
-    FSpLocationFromFullPath( strlen(path ) , path , spec ) ;
-}
-
 void wxUnixFilename2FSSpec( const char *path , FSSpec *spec )
 {
     wxString var = wxUnix2MacFilename( path ) ;
     wxMacFilename2FSSpec( var , spec ) ;
 }
-*/
+
 #endif
 void
 wxDos2UnixFilename (char *s)
@@ -1007,7 +1009,7 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
 bool
 wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
 {
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
     // CopyFile() copies file attributes and modification time too, so use it
     // instead of our code if available
     //
@@ -1113,7 +1115,10 @@ wxRenameFile (const wxString& file1, const wxString& file2)
 
 bool wxRemoveFile(const wxString& file)
 {
-#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#if defined(__VISUALC__) \
+ || defined(__BORLANDC__) \
+ || defined(__WATCOMC__) \
+ || defined(__GNUWIN32__)
   int res = wxRemove(file);
 #else
   int res = unlink(OS_FILENAME(file));
@@ -1131,7 +1136,7 @@ bool wxMkdir(const wxString& dir, int perm)
 
     // assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
     // for the GNU compiler
-#if (!(defined(__WXMSW__) || defined(__WXPM__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__)
+#if (!(defined(__WXMSW__) || defined(__WXPM__))) || (defined(__GNUWIN32__) && !defined(__MINGW32__)) || defined(__WXWINE__) || defined(__WXMICROWIN__)
     if ( mkdir(wxFNCONV(dirname), perm) != 0 )
 #elif defined(__WXPM__)
     if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's??
@@ -1177,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 &&
@@ -1194,12 +1206,13 @@ bool wxPathExists(const wxChar *pszPathName)
         (st.st_mode == S_IFDIR);
 #endif
 
+#endif
 }
 
 // Get a temporary filename, opening and closing the file.
 wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf)
 {
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
 
 #ifndef        __WIN32__
   wxChar tmp[144];
@@ -1818,7 +1831,7 @@ bool wxSetWorkingDirectory(const wxString& d)
 // On non-Windows platform, probably just return the empty string.
 wxString wxGetOSDirectory()
 {
-#ifdef __WINDOWS__
+#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
     wxChar buf[256];
     GetWindowsDirectory(buf, 256);
     return wxString(buf);