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>
This commit is contained in:
parent
76b114f849
commit
72e8f628e9
@ -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++ = '/';
|
||||
|
Loading…
x
Reference in New Issue
Block a user