Resolving aliases in a path
Resolving aliases in a path
- Subject: Resolving aliases in a path
- From: Michael Becker <email@hidden>
- Date: Sun, 25 Apr 2004 17:51:35 +0200
Hello!
I cannot figure out what I am doing wrong. I am trying to resolve
aliases in a path. I found the following code snipped on Apple's
Developer Sites, copy-pasted it (bad me), but it doesn't work. The
supplied path-Variable contains a valid path containing one alias'd
directory. The passed path is: '/Users/myself/Pictures/iPhoto
Library/AlbumData.xml' while the resolved path should be
'/Users/myself/Sites/iPhoto Library'.
The CFURLGetFSRef( url, &fsRef ) seems to return a "NO".
Are there any things that I am missing?
NSString *path; // Assume this exists.
NSString *resolvedPath = nil;
CFURLRef url;
url = CFURLCreateWithFileSystemPath(NULL /*allocator*/,
(CFStringRef)path,
kCFURLPOSIXPathStyle, NO /*isDirectory*/);
if(url != NULL)
{
FSRef fsRef;
if(CFURLGetFSRef(url, &fsRef))
{
// It never gets here!!!
Boolean targetIsFolder, wasAliased;
if (FSResolveAliasFile (&fsRef, true /*resolveAliasChains*/,
&targetIsFolder, &wasAliased) == noErr && wasAliased)
{
CFURLRef resolvedUrl = CFURLCreateFromFSRef(NULL, &fsRef);
if(resolvedUrl != NULL)
{
resolvedPath = (NSString*)
CFURLCopyFileSystemPath(resolvedUrl,
kCFURLPOSIXPathStyle);
CFRelease(resolvedUrl);
}
}
}
CFRelease(url);
}
if(resolvedPath==nil)
resolvedPath = [[NSString alloc] initWithString:path];
Best regards,
Michael
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.