[Libreoffice-commits] core.git: 2 commits - sal/osl
Tor Lillqvist
tml at iki.fi
Sun Jun 16 01:20:05 PDT 2013
sal/osl/unx/system.c | 110 ++++++++++++++++++++++++++++-----------------------
1 file changed, 61 insertions(+), 49 deletions(-)
New commits:
commit aa539f6c9d37f5eeef56a468f7009c542fddc02a
Author: Tor Lillqvist <tml at iki.fi>
Date: Sun Jun 16 11:02:32 2013 +0300
Don't use deprecated API for OS X alias resolving
Change-Id: Ifaaec1863f12cd73d0a77c3367935f57675157e2
diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c
index 1e9e249..a857769 100644
--- a/sal/osl/unx/system.c
+++ b/sal/osl/unx/system.c
@@ -135,14 +135,11 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
#if defined(MACOSX)
/*
* Add support for resolving Mac native alias files (not the same as unix alias files)
+ * (what are "unix alias files"?)
* returns 0 on success.
*/
int macxp_resolveAlias(char *path, int buflen)
{
- FSRef aFSRef;
- OSStatus nErr;
- Boolean bFolder;
- Boolean bAliased;
char *unprocessedPath = path;
if ( *unprocessedPath == '/' )
@@ -155,50 +152,65 @@ int macxp_resolveAlias(char *path, int buflen)
if ( unprocessedPath )
*unprocessedPath = '\0';
- nErr = noErr;
- bFolder = FALSE;
- bAliased = FALSE;
- if ( FSPathMakeRef( (const UInt8 *)path, &aFSRef, 0 ) == noErr )
+ CFStringRef cfpath = CFStringCreateWithCString( NULL, path, kCFStringEncodingUTF8 );
+ CFURLRef cfurl = CFURLCreateWithFileSystemPath( NULL, cfpath, kCFURLPOSIXPathStyle, false );
+ CFRelease( cfpath );
+ CFErrorRef cferror;
+ CFDataRef cfbookmark = CFURLCreateBookmarkDataFromFile( NULL, cfurl, &cferror );
+ CFRelease( cfurl );
+ if ( cfbookmark == NULL )
{
- nErr = FSResolveAliasFileWithMountFlags( &aFSRef, TRUE, &bFolder, &bAliased, kResolveAliasFileNoUI );
- if ( nErr == nsvErr )
+ CFRelease( cferror );
+ }
+ else
+ {
+ Boolean isStale;
+ cfurl = CFURLCreateByResolvingBookmarkData( NULL, cfbookmark, kCFBookmarkResolutionWithoutUIMask,
+ NULL, NULL, &isStale, &cferror );
+ CFRelease( cfbookmark );
+ if ( cfurl == NULL )
{
- errno = ENOENT;
- nRet = -1;
+ CFRelease( cferror );
}
- else if ( nErr == noErr && bAliased )
+ else
{
- char tmpPath[ PATH_MAX ];
- if ( FSRefMakePath( &aFSRef, (UInt8 *)tmpPath, PATH_MAX ) == noErr )
+ cfpath = CFURLCopyFileSystemPath( cfurl, kCFURLPOSIXPathStyle );
+ CFRelease( cfurl );
+ if ( cfpath != NULL )
{
- int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
- if ( nLen < buflen && nLen < PATH_MAX )
+ char tmpPath[ PATH_MAX ];
+ if ( CFStringGetCString( cfpath, tmpPath, PATH_MAX, kCFStringEncodingUTF8 ) )
{
- if ( unprocessedPath )
+ int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
+ if ( nLen < buflen && nLen < PATH_MAX )
{
- int nTmpPathLen = strlen( tmpPath );
- strcat( tmpPath, "/" );
- strcat( tmpPath, unprocessedPath + 1 );
- strcpy( path, tmpPath);
- unprocessedPath = path + nTmpPathLen;
+ 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 if ( !unprocessedPath )
+ else
{
- strcpy( path, tmpPath);
+ errno = ENAMETOOLONG;
+ nRet = -1;
}
}
- else
- {
- errno = ENAMETOOLONG;
- nRet = -1;
- }
+ CFRelease( cfpath );
}
}
}
if ( unprocessedPath )
*unprocessedPath++ = '/';
- }
+ }
return nRet;
}
commit 027d114b832686ab927c7db91ea512d2dcdc77ac
Author: Tor Lillqvist <tml at iki.fi>
Date: Sun Jun 16 10:37:09 2013 +0300
Indent macxp_resolveAlias() consistently
Change-Id: I66ab13c4111678f20a09f14126304a0c11116180
diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c
index 8c8280d..1e9e249 100644
--- a/sal/osl/unx/system.c
+++ b/sal/osl/unx/system.c
@@ -146,58 +146,58 @@ int macxp_resolveAlias(char *path, int buflen)
char *unprocessedPath = path;
if ( *unprocessedPath == '/' )
- unprocessedPath++;
+ unprocessedPath++;
int nRet = 0;
while ( !nRet && unprocessedPath && *unprocessedPath )
- {
+ {
unprocessedPath = strchr( unprocessedPath, '/' );
if ( unprocessedPath )
- *unprocessedPath = '\0';
+ *unprocessedPath = '\0';
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;
+ {
+ 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;
+ }
+ }
+ }
+ }
if ( unprocessedPath )
- *unprocessedPath++ = '/';
+ *unprocessedPath++ = '/';
}
return nRet;
More information about the Libreoffice-commits
mailing list