[Libreoffice-commits] core.git: sal/osl

Douglas Mencken dougmencken at gmail.com
Mon Feb 24 09:01:19 PST 2014


 sal/osl/unx/system.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 61 insertions(+), 4 deletions(-)

New commits:
commit 72e8f628e9204a5f5561efcd1e5a8cac4152f16e
Author: Douglas Mencken <dougmencken at gmail.com>
Date:   Sun Feb 23 15:16:26 2014 -0500

    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 at libreoffice.org>
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c
index a50996a..82ea485 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++ = '/';


More information about the Libreoffice-commits mailing list