+#if defined(__WXMAC__) && !defined(__WXOSX_IPHONE__)
+
+#define kDefaultPathStyle kCFURLPOSIXPathStyle
+
+wxString wxMacFSRefToPath( const FSRef *fsRef , CFStringRef additionalPathComponent )
+{
+ CFURLRef fullURLRef;
+ fullURLRef = CFURLCreateFromFSRef(NULL, fsRef);
+ if ( additionalPathComponent )
+ {
+ CFURLRef parentURLRef = fullURLRef ;
+ fullURLRef = CFURLCreateCopyAppendingPathComponent(NULL, parentURLRef,
+ additionalPathComponent,false);
+ CFRelease( parentURLRef ) ;
+ }
+ CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, kDefaultPathStyle);
+ CFRelease( fullURLRef ) ;
+ CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
+ CFRelease( cfString );
+ CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
+ return wxCFStringRef(cfMutableString).AsString();
+}
+
+OSStatus wxMacPathToFSRef( const wxString&path , FSRef *fsRef )
+{
+ OSStatus err = noErr ;
+ CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, wxCFStringRef(path));
+ CFStringNormalize(cfMutableString,kCFStringNormalizationFormD);
+ CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kDefaultPathStyle, false);
+ CFRelease( cfMutableString );
+ if ( NULL != url )
+ {
+ if ( CFURLGetFSRef(url, fsRef) == false )
+ err = fnfErr ;
+ CFRelease( url ) ;
+ }
+ else
+ {
+ err = fnfErr ;
+ }
+ return err ;
+}
+
+wxString wxMacHFSUniStrToString( ConstHFSUniStr255Param uniname )
+{
+ CFStringRef cfname = CFStringCreateWithCharacters( kCFAllocatorDefault,
+ uniname->unicode,
+ uniname->length );
+ CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfname);
+ CFRelease( cfname );
+ CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
+ return wxCFStringRef(cfMutableString).AsString() ;
+}
+
+#ifndef __LP64__
+
+wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
+{
+ FSRef fsRef ;
+ if ( FSpMakeFSRef( spec , &fsRef) == noErr )
+ {
+ return wxMacFSRefToPath( &fsRef ) ;
+ }
+ return wxEmptyString ;
+}
+
+void wxMacFilename2FSSpec( const wxString& path , FSSpec *spec )
+{
+ OSStatus err = noErr;
+ FSRef fsRef;
+ wxMacPathToFSRef( path , &fsRef );
+ err = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, spec, NULL);
+ verify_noerr( err );
+}
+#endif
+
+#endif // __WXMAC__
+
+template<typename T>
+static void wxDoDos2UnixFilename(T *s)