diff options
author | Douglas Mencken <dougmencken@gmail.com> | 2014-02-23 15:16:26 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-02-24 17:00:51 +0000 |
commit | 72e8f628e9204a5f5561efcd1e5a8cac4152f16e (patch) | |
tree | ed8bbf31bc5c5b8fe79d2f39d779ad71d07f0b80 /sal | |
parent | 76b114f849645f42311c0553b3320532bb26049c (diff) |
Use "deprecated" API for OS X alias resolving on X 10.5
Change-Id: I68a49b95c9b4f4d1d0472a298f8b29d83435c88e
Reviewed-on: https://gerrit.libreoffice.org/8195
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/system.c | 65 |
1 files changed, 61 insertions, 4 deletions
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++ = '/'; |