diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c index a50996a66dde..82ea48587784 100644 --- a/sal/osl/unx/system.c +++ b/sal/osl/unx/system.c @@ -157,6 +157,18 @@ int macxp_resolveAlias(char *path, int buflen) (void) buflen; return 0; #else +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + FSRef aFSRef; + OSStatus nErr; + Boolean bFolder; + Boolean bAliased; +#else + CFStringRef cfpath; + CFURLRef cfurl; + CFErrorRef cferror; + CFDataRef cfbookmark; +#endif + char *unprocessedPath = path; if ( *unprocessedPath == '/' ) @@ -169,12 +181,56 @@ int macxp_resolveAlias(char *path, int buflen) if ( unprocessedPath ) *unprocessedPath = '\0'; - CFStringRef cfpath = CFStringCreateWithCString( NULL, path, kCFStringEncodingUTF8 ); - CFURLRef cfurl = CFURLCreateWithFileSystemPath( NULL, cfpath, kCFURLPOSIXPathStyle, false ); +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 + nErr = noErr; + bFolder = FALSE; + bAliased = FALSE; + + if ( FSPathMakeRef( (const UInt8 *)path, &aFSRef, 0 ) == noErr ) + { + nErr = FSResolveAliasFileWithMountFlags( &aFSRef, TRUE, &bFolder, &bAliased, kResolveAliasFileNoUI ); + if ( nErr == nsvErr ) + { + errno = ENOENT; + nRet = -1; + } + else if ( nErr == noErr && bAliased ) + { + char tmpPath[ PATH_MAX ]; + if ( FSRefMakePath( &aFSRef, (UInt8 *)tmpPath, PATH_MAX ) == noErr ) + { + int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 ); + if ( nLen < buflen && nLen < PATH_MAX ) + { + if ( unprocessedPath ) + { + int nTmpPathLen = strlen( tmpPath ); + strcat( tmpPath, "/" ); + strcat( tmpPath, unprocessedPath + 1 ); + strcpy( path, tmpPath); + unprocessedPath = path + nTmpPathLen; + } + else if ( !unprocessedPath ) + { + strcpy( path, tmpPath); + } + } + else + { + errno = ENAMETOOLONG; + nRet = -1; + } + } + } + } +#else + cfpath = CFStringCreateWithCString( NULL, path, kCFStringEncodingUTF8 ); + cfurl = CFURLCreateWithFileSystemPath( NULL, cfpath, kCFURLPOSIXPathStyle, false ); CFRelease( cfpath ); - CFErrorRef cferror = NULL; - CFDataRef cfbookmark = CFURLCreateBookmarkDataFromFile( NULL, cfurl, &cferror ); + cferror = NULL; + cfbookmark = CFURLCreateBookmarkDataFromFile( NULL, cfurl, &cferror ); CFRelease( cfurl ); + if ( cfbookmark == NULL ) { if(cferror) @@ -227,6 +283,7 @@ int macxp_resolveAlias(char *path, int buflen) } } } +#endif if ( unprocessedPath ) *unprocessedPath++ = '/';