Kaydet (Commit) 72e8f628 authored tarafından Douglas Mencken's avatar Douglas Mencken Kaydeden (comit) Norbert Thiebaud

Use "deprecated" API for OS X alias resolving on X 10.5

Change-Id: I68a49b95c9b4f4d1d0472a298f8b29d83435c88e
Reviewed-on: https://gerrit.libreoffice.org/8195Tested-by: 's avatarLibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst 76b114f8
......@@ -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++ = '/';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment