Re: dealing with alias files, finding URL to target file
Re: dealing with alias files, finding URL to target file
- Subject: Re: dealing with alias files, finding URL to target file
- From: Ken Thomases <email@hidden>
- Date: Fri, 15 Apr 2011 10:44:06 -0500
On Apr 15, 2011, at 10:20 AM, Sean McBride wrote:
> Of late, I've been working to remove NSString-based paths, FSRefs, and
> Alias Manager usage in my code, in favour of NSURL.
>
> But I'm having trouble with alias files.
>
> NSOpenPanel helpfully, by default, resolves aliases before it returns
> the URL to you. But NSPathControl does not and file drops that you get
> off NSPasteboard also do not. So in many cases I need to manually check
> if a URL points to an alias file, and find the file it points to. Am I
> missing an easy/modern way to do this?
Yes. Bookmark data is the modern replacement for alias records. The new bookmark APIs are backward compatible with aliases, including alias files. See the documentation for +[NSURL bookmarkDataWithContentsOfURL:error:]. You'd follow that with -URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden