From 16d2852d25a1c2c90ac5a2f90f7753564b082afc Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 26 May 2010 10:22:48 +0200 Subject: [PATCH] vcl112: #i111819# resolve aliases --- fpicker/source/aqua/FilterHelper.cxx | 11 ++++++++ fpicker/source/aqua/NSURL_OOoAdditions.hxx | 13 +++++++--- fpicker/source/aqua/NSURL_OOoAdditions.mm | 30 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/fpicker/source/aqua/FilterHelper.cxx b/fpicker/source/aqua/FilterHelper.cxx index 10e429f201c5..9c644326005e 100644 --- a/fpicker/source/aqua/FilterHelper.cxx +++ b/fpicker/source/aqua/FilterHelper.cxx @@ -35,6 +35,7 @@ // #endif #include "CFStringUtilities.hxx" #include "NSString_OOoAdditions.hxx" +#include "NSURL_OOoAdditions.hxx" #include "FilterHelper.hxx" @@ -428,6 +429,16 @@ sal_Bool FilterHelper::filenameMatchesFilter(NSString* sFilename) } } + // might be an alias + NSString* pResolved = resolveAlias( sFilename ); + if( pResolved ) + { + sal_Bool bResult = filenameMatchesFilter( pResolved ); + [pResolved autorelease]; + if( bResult ) + return sal_True; + } + DBG_PRINT_EXIT(CLASS_NAME, __func__); return sal_False; diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.hxx b/fpicker/source/aqua/NSURL_OOoAdditions.hxx index 8be2c0362096..31b55385e155 100644 --- a/fpicker/source/aqua/NSURL_OOoAdditions.hxx +++ b/fpicker/source/aqua/NSURL_OOoAdditions.hxx @@ -29,15 +29,20 @@ #define _NSURL_OOOADDITIONS_HXX_ #include -#include +#include #include #include "CFStringUtilities.hxx" #include -// #include - @interface NSURL (OOoAdditions) - (rtl::OUString) OUStringForInfo:(InfoType)info; @end -#endif \ No newline at end of file +/* + returns the resolved string if there was an alias + if there was no alias, nil is returned +*/ + +NSString* resolveAlias( NSString* i_pSystemPath ); + +#endif diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.mm b/fpicker/source/aqua/NSURL_OOoAdditions.mm index 56fc198650c8..ecc38b7e232b 100644 --- a/fpicker/source/aqua/NSURL_OOoAdditions.mm +++ b/fpicker/source/aqua/NSURL_OOoAdditions.mm @@ -80,3 +80,33 @@ return sResult; } @end + +NSString* resolveAlias( NSString* i_pSystemPath ) +{ + NSString* pResolvedPath = nil; + CFURLRef rUrl = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, + (CFStringRef)i_pSystemPath, + kCFURLPOSIXPathStyle, false); + if( rUrl != NULL ) + { + FSRef rFS; + if( CFURLGetFSRef( rUrl, &rFS ) ) + { + MacOSBoolean bIsFolder = false; + MacOSBoolean bAlias = false; + OSErr err = FSResolveAliasFile( &rFS, true, &bIsFolder, &bAlias); + if( (err == noErr) && bAlias ) + { + CFURLRef rResolvedUrl = CFURLCreateFromFSRef( kCFAllocatorDefault, &rFS ); + if( rResolvedUrl != NULL ) + { + pResolvedPath = (NSString*)CFURLCopyFileSystemPath( rResolvedUrl, kCFURLPOSIXPathStyle ); + CFRelease( rResolvedUrl ); + } + } + } + CFRelease( rUrl ); + } + + return pResolvedPath; +}