Re: Locating moved or renamed file
Re: Locating moved or renamed file
- Subject: Re: Locating moved or renamed file
- From: Nick Zitzmann <email@hidden>
- Date: Sat, 8 Nov 2003 22:16:14 -0800
On Nov 8, 2003, at 9:45 PM, Bartlomiej Cichosz wrote:
If I store a reference to a file as path and filename, whenever the
file is renamed or moved, I loose that link. This does not happen, for
example, in iTunes - the app appears to be keeping track of songs in
its library even if they are moved or renamed via Finder.
iTunes probably uses alias records to track files as they are moved
around the disk. This can be done with the Carbon Alias Manager, where
one would use functions like FSNewAlias() and FSResolveAlias() to
convert between AliasHandle and FSRef structures. While Cocoa doesn't
have any built-in methods that use FSRef structures, there are at least
two ways to translate between FSRef structures and file paths - using
CFURL from CoreFoundation, and using some Carbon File Manager
functions.
Do keep in mind, though, that this magic only works on HFS+ and AFP
file systems. Alias records, IIRC, can't keep track of moved files on
UFS and other file systems.
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
S/MIME signature available upon request
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
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.