Re: How do I get a file reference w/o relying on the path?
Re: How do I get a file reference w/o relying on the path?
- Subject: Re: How do I get a file reference w/o relying on the path?
- From: Brad Stone <email@hidden>
- Date: Sat, 3 Apr 2010 19:43:50 -0400
Very interesting. According to the documentation if I want to store the reference and want it to persist after a reboot I need to do a bookmark.
You should not store or archive file reference URLs. A file’s ID may be different for different boots of the operating system. If you need to store a URL, see “Working with Bookmarks and Aliases.”
THANK YOU so much for pointing me in the correct direction.
On Apr 3, 2010, at 6:55 PM, Ken Thomases wrote:
> On Apr 3, 2010, at 5:20 PM, Brad Stone wrote:
>
>> I want to store a reference to a file in an ivar that will allow the user to change the file's name and/or the directory (i.e. the path) and still allow me to access it. I don't want to create a file (like an ailas). I need to store the file reference in a variable so I can open the file no matter where the user moves it or renames it.
>
> FSRefs have the property you desire. As of Snow Leopard, though, the new recommended technique is to use a file reference NSURL. Check the NSURL documentation and also:
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/LowLevelFileMgmt/Articles/FileManagementNSURL.html
>
>
> Note that an alias _record_ is different from an alias _file_. An alias record is data in memory and is suitable for this purpose, but perhaps overkill.
>
> As of Snow Leopard, alias records are deprecated in favor of bookmark data, but, again, it's probably overkill. (Both alias records and bookmark data are more suitable if the reference is to be persisted for use by a later process. Also, both can apply more robust searching heuristics to find an appropriate file even if it isn't the original. For example, if the original is deleted and replaced with a new file of the same name.)
>
> 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