• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Resolving aliases in a path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Resolving aliases in a path (From: Michael Becker <email@hidden>)

  • Prev by Date: control autoresizing problem
  • Next by Date: Re: Unarchive consistency errors
  • Previous by thread: Resolving aliases in a path
  • Next by thread: Okay to leave -concludeDragOperation: empty?
  • Index(es):
    • Date
    • Thread