]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/filefn.cpp
wxComboCtrlBase: Fix SEGV due to double deletion where SetPopupControl is called...
[wxWidgets.git] / src / common / filefn.cpp
index 3bd9d7c1bb524a9d75a546c3d8092f844292c74b..5824391e0f770f77d747f32643406b284113a96c 100644 (file)
@@ -299,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__
 }
@@ -878,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 )
@@ -903,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 )