]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filefn.cpp
wxColour lost its Create method, use direct creation for XTI
[wxWidgets.git] / src / common / filefn.cpp
index 81f3e18eb1741e7eedd3b50f33feb8acbe811acb..5824391e0f770f77d747f32643406b284113a96c 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/utils.h"
 #endif
 
-#include "wx/utils.h"
 #include "wx/file.h" // This does include filefn.h
 #include "wx/filename.h"
 #include "wx/dir.h"
@@ -52,8 +53,6 @@
     #include  "wx/mac/private.h"  // includes mac headers
 #endif
 
-#include "wx/log.h"
-
 #ifdef __WINDOWS__
     #include "wx/msw/private.h"
     #include "wx/msw/mslu.h"
@@ -300,16 +299,19 @@ wxFileExists (const wxString& filename)
 
     return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
 #else // !__WIN32__
+    #ifndef S_ISREG
+        #define S_ISREG(mode) ((mode) & S_IFREG)
+    #endif
     wxStructStat st;
 #ifndef wxNEED_WX_UNISTD_H
-    return (wxStat( filename.fn_str() , &st) == 0 && (st.st_mode & S_IFREG))
+    return (wxStat( filename.fn_str() , &st) == 0 && S_ISREG(st.st_mode))
 #ifdef __OS2__
       || (errno == EACCES) // if access is denied something with that name
                             // exists and is opened in exclusive mode.
 #endif
       ;
 #else
-    return wxStat( filename , &st) == 0 && (st.st_mode & S_IFREG);
+    return wxStat( filename , &st) == 0 && S_ISREG(st.st_mode);
 #endif
 #endif // __WIN32__/!__WIN32__
 }
@@ -879,13 +881,19 @@ wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathCompon
     }
     CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, kDefaultPathStyle);
     CFRelease( fullURLRef ) ;
-    return wxMacCFStringHolder(cfString).AsString(wxLocale::GetSystemEncoding());
+    CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
+    CFRelease( cfString );
+    CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);    
+    return wxMacCFStringHolder(cfMutableString).AsString(wxLocale::GetSystemEncoding());
 }
 
 OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef )
 {
     OSStatus err = noErr ;
-    CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, wxMacCFStringHolder(path ,wxLocale::GetSystemEncoding() ) , kDefaultPathStyle, false);
+    CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, wxMacCFStringHolder(path ,wxLocale::GetSystemEncoding() ) ) ;
+    CFStringNormalize(cfMutableString,kCFStringNormalizationFormD);    
+    CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kDefaultPathStyle, false);
+    CFRelease( cfMutableString );
     if ( NULL != url )
     {
         if ( CFURLGetFSRef(url, fsRef) == false )
@@ -904,7 +912,10 @@ wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname )
     CFStringRef cfname = CFStringCreateWithCharacters( kCFAllocatorDefault,
                                                       uniname->unicode,
                                                       uniname->length );
-    return wxMacCFStringHolder(cfname).AsString() ;
+    CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfname);
+    CFRelease( cfname );
+    CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);    
+    return wxMacCFStringHolder(cfMutableString).AsString() ;
 }
 
 wxString wxMacFSSpec2MacFilename( const FSSpec *spec )