-#ifdef __WXMAC__
-void
-wxMac2UnixFilename (char *s)
-{
- if (s)
- {
- memmove( s+1 , s ,strlen( s ) + 1) ;
- if ( *s == ':' )
- *s = '.' ;
- else
- *s = '/' ;
-
- while (*s)
- {
- if (*s == ':')
- *s = '/';
- else
- *s = wxToLower (*s); // Case INDEPENDENT
- s++;
- }
- }
-}
-
-void
-wxUnix2MacFilename (char *s)
-{
- if (s)
- {
- if ( *s == '.' )
- {
- // relative path , since it goes on with slash which is translated to a :
- memmove( s , s+1 ,strlen( s ) ) ;
- }
- else if ( *s == '/' )
- {
- // absolute path -> on mac just start with the drive name
- memmove( s , s+1 ,strlen( s ) ) ;
- }
- else
- {
- wxASSERT_MSG( 1 , "unkown path beginning" ) ;
- }
- while (*s)
- {
- if (*s == '/' || *s == '\\')
- *s = ':';
-
- s++ ;
- }
- }
+#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 );