]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filefn.cpp
removed stubs and qt 'ports'
[wxWidgets.git] / src / common / filefn.cpp
index f9aa7c75eaa4677287ea022ce51abe78b3572804..8108e29a516b27dd23b4be63b202ad41886fb2e6 100644 (file)
@@ -142,11 +142,7 @@ const off_t wxInvalidOffset = (off_t)-1;
 // ----------------------------------------------------------------------------
 
 // we need to translate Mac filenames before passing them to OS functions
-#ifdef __MAC__
-    #define OS_FILENAME(s) (wxUnix2MacFilename(s))
-#else
     #define OS_FILENAME(s) (s.fn_str())
-#endif
 
 // ============================================================================
 // implementation
@@ -500,7 +496,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
       }
       else
 #else
-    while ((*d++ = *s) != NULL) {
+    while ((*d++ = *s) != 0) {
 #  ifndef __WXMSW__
         if (*s == wxT('\\')) {
             if ((*(d - 1) = *++s)) {
@@ -520,7 +516,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
             register wxChar  *start = d;
             register int     braces = (*s == wxT('{') || *s == wxT('('));
             register wxChar  *value;
-            while ((*d++ = *s) != NULL)
+            while ((*d++ = *s) != 0)
                 if (braces ? (*s == wxT('}') || *s == wxT(')')) : !(wxIsalnum(*s) || *s == wxT('_')) )
                     break;
                 else
@@ -528,7 +524,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
             *--d = 0;
             value = wxGetenv(braces ? start + 1 : start);
             if (value) {
-                for ((d = start - 1); (*d++ = *value++) != NULL;);
+                for ((d = start - 1); (*d++ = *value++) != 0;);
                 d--;
                 if (braces && *s)
                     s++;
@@ -580,7 +576,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name)
           *(d - 1) = SEP;
     }
     s = nm;
-    while ((*d++ = *s++) != NULL);
+    while ((*d++ = *s++) != 0);
     delete[] nm_tmp; // clean up alloc
     /* Now clean up the buffer */
     return wxRealPath(buf);
@@ -652,11 +648,15 @@ wxChar *wxFileNameFromPath (wxChar *path)
       tcp = path + wxStrlen (path);
       while (--tcp >= path)
         {
+#ifdef __WXMAC__
+          if (*tcp == wxT(':') )
+#else
           if (*tcp == wxT('/') || *tcp == wxT('\\')
 #ifdef __VMS__
      || *tcp == wxT(':') || *tcp == wxT(']'))
 #else
      )
+#endif
 #endif
             return tcp + 1;
         }                        /* while */
@@ -679,11 +679,15 @@ wxString wxFileNameFromPath (const wxString& path1)
       tcp = path + wxStrlen (path);
       while (--tcp >= path)
           {
+#ifdef __WXMAC__
+           if (*tcp == wxT(':') )
+#else
             if (*tcp == wxT('/') || *tcp == wxT('\\')
 #ifdef __VMS__
         || *tcp == wxT(':') || *tcp == wxT(']'))
 #else
         )
+#endif
 #endif
                 return wxString(tcp + 1);
             }                        /* while */
@@ -717,7 +721,11 @@ wxPathOnly (wxChar *path)
       while (!done && i > -1)
       {
         // ] is for VMS
+#ifdef __WXMAC__
+        if (path[i] == wxT(':') )
+#else
         if (path[i] == wxT('/') || path[i] == wxT('\\') || path[i] == wxT(']'))
+#endif
         {
           done = TRUE;
 #ifdef __VMS__
@@ -766,7 +774,11 @@ wxString wxPathOnly (const wxString& path)
       while (!done && i > -1)
       {
         // ] is for VMS
+#ifdef __WXMAC__
+        if (path[i] == wxT(':') )
+#else
         if (path[i] == wxT('/') || path[i] == wxT('\\') || path[i] == wxT(']'))
+#endif
         {
           done = TRUE;
 #ifdef __VMS__
@@ -801,7 +813,30 @@ wxString wxPathOnly (const wxString& path)
 // Also, convert to lower case, since case is significant in UNIX.
 
 #if defined(__WXMAC__) && !defined(__UNIX__)
+wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
+{
+    Handle    myPath ;
+    short     length ;
+
+    FSpGetFullPath( spec , &length , &myPath ) ;
+    ::SetHandleSize( myPath , length + 1 ) ;
+    ::HLock( myPath ) ;
+    (*myPath)[length] = 0 ;
+    if ( length > 0 && (*myPath)[length-1] ==':' )
+        (*myPath)[length-1] = 0 ;
+
+    wxString result(     (char*) *myPath ) ;
+    ::HUnlock( myPath ) ;
+    ::DisposeHandle( myPath ) ;
+    return result ;
+}
 
+void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
+{
+    FSpLocationFromFullPath( strlen(path ) , path , spec ) ;
+}
+
+/*
 static char sMacFileNameConversion[ 1000 ] ;
 
 wxString wxMac2UnixFilename (const char *str)
@@ -868,24 +903,6 @@ wxString wxUnix2MacFilename (const char *str)
   return wxString (sMacFileNameConversion) ;
 }
 
-wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
-{
-    Handle    myPath ;
-    short     length ;
-
-    FSpGetFullPath( spec , &length , &myPath ) ;
-    ::SetHandleSize( myPath , length + 1 ) ;
-    ::HLock( myPath ) ;
-    (*myPath)[length] = 0 ;
-    if ( length > 0 && (*myPath)[length-1] ==':' )
-        (*myPath)[length-1] = 0 ;
-
-    wxString result(     (char*) *myPath ) ;
-    ::HUnlock( myPath ) ;
-    ::DisposeHandle( myPath ) ;
-    return result ;
-}
-
 wxString wxMacFSSpec2UnixFilename( const FSSpec *spec )
 {
     return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
@@ -901,7 +918,7 @@ void wxUnixFilename2FSSpec( const char *path , FSSpec *spec )
     wxString var = wxUnix2MacFilename( path ) ;
     wxMacFilename2FSSpec( var , spec ) ;
 }
-
+*/
 #endif
 void
 wxDos2UnixFilename (char *s)
@@ -950,9 +967,9 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
   FILE *fp2 = (FILE *) NULL;
   FILE *fp3 = (FILE *) NULL;
   // Open the inputs and outputs
-  if ((fp1 = fopen (OS_FILENAME( file1 ), "rb")) == NULL ||
-      (fp2 = fopen (OS_FILENAME( file2 ), "rb")) == NULL ||
-      (fp3 = fopen (OS_FILENAME( outfile ), "wb")) == NULL)
+  if ((fp1 = wxFopen (OS_FILENAME( file1 ), wxT("rb"))) == NULL ||
+      (fp2 = wxFopen (OS_FILENAME( file2 ), wxT("rb"))) == NULL ||
+      (fp3 = wxFopen (OS_FILENAME( outfile ), wxT("wb"))) == NULL)
     {
       if (fp1)
         fclose (fp1);
@@ -1099,7 +1116,7 @@ bool wxRemoveFile(const wxString& file)
 bool wxMkdir(const wxString& dir, int perm)
 {
 #if defined(__WXMAC__) && !defined(__UNIX__)
-  return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
+  return (mkdir( dir , 0 ) == 0);
 #else // !Mac
     const wxChar *dirname = dir.c_str();
 
@@ -1395,7 +1412,7 @@ wxString wxFindFirstFile(const wxChar *spec, int flags)
 
     FSSpec fsspec ;
 
-    wxUnixFilename2FSSpec( result , &fsspec ) ;
+    wxMacFilename2FSSpec( result , &fsspec ) ;
     g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
     g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
     g_iter.m_index = 0 ;
@@ -1443,7 +1460,7 @@ wxString wxFindNextFile()
                                    g_iter.m_name,
                                    &spec) ;
 
-    return wxMacFSSpec2UnixFilename( &spec ) ;
+    return wxMacFSSpec2MacFilename( &spec ) ;
 }
 
 #elif defined(__WXMSW__)
@@ -1697,7 +1714,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
                cwdSpec.vRefNum = pb.ioFCBVRefNum;
                cwdSpec.parID = pb.ioFCBParID;
                cwdSpec.name[0] = 0 ;
-               wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
+               wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
                
                strcpy( buf , res ) ;
                buf[res.length()-1]=0 ;