Re: Resolving aliases in a path
Re: Resolving aliases in a path
- Subject: Re: Resolving aliases in a path
- From: Charles Srstka <email@hidden>
- Date: Sun, 25 Apr 2004 12:03:52 -0500
On Apr 25, 2004, at 10:51 AM, Michael Becker wrote:
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'.
This works for me:
- (NSString *)resolveAliasFileAtPath:(NSString *)path {
NSFileManager *fm = [NSFileManager defaultManager];
FSRef fileRef;
NSString *newPath;
BOOL targetIsFolder;
char cPath[1024];
BOOL wasAliased;
OSErr err = noErr;
err = FSPathMakeRef([path fileSystemRepresentation],&fileRef,NULL);
if(err != noErr)
return nil;
err = FSResolveAliasFile(&fileRef,YES,&targetIsFolder,&wasAliased);
if(err != noErr)
return nil;
err = FSRefMakePath(&fileRef,cPath,sizeof(cPath));
if(err != noErr)
return nil;
newPath = [fm stringWithFileSystemRepresentation:cPath
length:strlen(cPath)];
return newPath;
}
Charles
_______________________________________________
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.