• 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
Resolving aliases in a path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Resolving aliases in a path
      • From: Charles Srstka <email@hidden>
  • Prev by Date: Unarchive consistency errors
  • Next by Date: Re: Creating a criteria search view
  • Previous by thread: RE: Unarchive consistency errors
  • Next by thread: Re: Resolving aliases in a path
  • Index(es):
    • Date
    • Thread