Don't use deprecated API for OS X alias resolving
Change-Id: Ifaaec1863f12cd73d0a77c3367935f57675157e2
This commit is contained in:
@@ -135,14 +135,11 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
|
|||||||
#if defined(MACOSX)
|
#if defined(MACOSX)
|
||||||
/*
|
/*
|
||||||
* Add support for resolving Mac native alias files (not the same as unix alias files)
|
* Add support for resolving Mac native alias files (not the same as unix alias files)
|
||||||
|
* (what are "unix alias files"?)
|
||||||
* returns 0 on success.
|
* returns 0 on success.
|
||||||
*/
|
*/
|
||||||
int macxp_resolveAlias(char *path, int buflen)
|
int macxp_resolveAlias(char *path, int buflen)
|
||||||
{
|
{
|
||||||
FSRef aFSRef;
|
|
||||||
OSStatus nErr;
|
|
||||||
Boolean bFolder;
|
|
||||||
Boolean bAliased;
|
|
||||||
char *unprocessedPath = path;
|
char *unprocessedPath = path;
|
||||||
|
|
||||||
if ( *unprocessedPath == '/' )
|
if ( *unprocessedPath == '/' )
|
||||||
@@ -155,21 +152,34 @@ int macxp_resolveAlias(char *path, int buflen)
|
|||||||
if ( unprocessedPath )
|
if ( unprocessedPath )
|
||||||
*unprocessedPath = '\0';
|
*unprocessedPath = '\0';
|
||||||
|
|
||||||
nErr = noErr;
|
CFStringRef cfpath = CFStringCreateWithCString( NULL, path, kCFStringEncodingUTF8 );
|
||||||
bFolder = FALSE;
|
CFURLRef cfurl = CFURLCreateWithFileSystemPath( NULL, cfpath, kCFURLPOSIXPathStyle, false );
|
||||||
bAliased = FALSE;
|
CFRelease( cfpath );
|
||||||
if ( FSPathMakeRef( (const UInt8 *)path, &aFSRef, 0 ) == noErr )
|
CFErrorRef cferror;
|
||||||
|
CFDataRef cfbookmark = CFURLCreateBookmarkDataFromFile( NULL, cfurl, &cferror );
|
||||||
|
CFRelease( cfurl );
|
||||||
|
if ( cfbookmark == NULL )
|
||||||
{
|
{
|
||||||
nErr = FSResolveAliasFileWithMountFlags( &aFSRef, TRUE, &bFolder, &bAliased, kResolveAliasFileNoUI );
|
CFRelease( cferror );
|
||||||
if ( nErr == nsvErr )
|
|
||||||
{
|
|
||||||
errno = ENOENT;
|
|
||||||
nRet = -1;
|
|
||||||
}
|
}
|
||||||
else if ( nErr == noErr && bAliased )
|
else
|
||||||
|
{
|
||||||
|
Boolean isStale;
|
||||||
|
cfurl = CFURLCreateByResolvingBookmarkData( NULL, cfbookmark, kCFBookmarkResolutionWithoutUIMask,
|
||||||
|
NULL, NULL, &isStale, &cferror );
|
||||||
|
CFRelease( cfbookmark );
|
||||||
|
if ( cfurl == NULL )
|
||||||
|
{
|
||||||
|
CFRelease( cferror );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfpath = CFURLCopyFileSystemPath( cfurl, kCFURLPOSIXPathStyle );
|
||||||
|
CFRelease( cfurl );
|
||||||
|
if ( cfpath != NULL )
|
||||||
{
|
{
|
||||||
char tmpPath[ PATH_MAX ];
|
char tmpPath[ PATH_MAX ];
|
||||||
if ( FSRefMakePath( &aFSRef, (UInt8 *)tmpPath, PATH_MAX ) == noErr )
|
if ( CFStringGetCString( cfpath, tmpPath, PATH_MAX, kCFStringEncodingUTF8 ) )
|
||||||
{
|
{
|
||||||
int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
|
int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
|
||||||
if ( nLen < buflen && nLen < PATH_MAX )
|
if ( nLen < buflen && nLen < PATH_MAX )
|
||||||
@@ -193,6 +203,8 @@ int macxp_resolveAlias(char *path, int buflen)
|
|||||||
nRet = -1;
|
nRet = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CFRelease( cfpath );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user