Re: Trashing files and undo
Re: Trashing files and undo
- Subject: Re: Trashing files and undo
- From: Charles Srstka <email@hidden>
- Date: Sat, 12 Jul 2008 11:49:54 -0500
On Jul 12, 2008, at 2:25 AM, Ruotger Skupin wrote:
Hi,
if I get you right, you are suggesting I put an alias to the file
into (say) ~/Library/Application Support/MyApp/UndoAliases/ remember
the original path/filename then trash the file. To get it back I
resolve the alias and move/rename it.
What's the advantage over the FSRef solution Charles proposed?
He's not referring to making an alias *file*, just an alias in memory.
To do that, you make an FSRef first as I described, then you use
FSNewAlias() with NULL as the first argument, a pointer to your FSRef
as the second argument, and a pointer to an AliasHandle as the third
argument. Later, you can use FSResolveAlias() to get the FSRef back,
and then you resolve the FSRef into a file path.
The advantage is, as Gregory mentioned, that you can store the alias
in your preferences (after encoding it to an NSData or something) and
load it back again the next time your program launches. I also think
FSRefs don't stay valid if the disk that the file is on gets ejected,
although I may be wrong about that one. My guess is that Undo support
doesn't really need to persist across program launches, so in my
opinion you'd be fine with an FSRef, although doing a little extra
work and getting an AliasHandle wouldn't really hurt anything. It's up
to you, I guess.
Charles
_______________________________________________
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