Re: Trashing files and undo
Re: Trashing files and undo
- Subject: Re: Trashing files and undo
- From: Charles Srstka <email@hidden>
- Date: Fri, 11 Jul 2008 10:54:47 -0500
On Jul 11, 2008, at 10:44 AM, Gregory Weston wrote:
Drop-dead simple. FSFindFolder is your friend. Give it a volume
reference number and tell it you're looking for the user's trash and
it'll hand it back to you (creating it if necessary and you asked
for that behavior).
I think possibly a bigger issue here is going to be that moving
files to the trash can cause them to be renamed. At least doing so
in Finder can; I'm not sure if the NSWorkspace routine does the
same. You'll need a reliable way to track the file and map that back
to the original location and name. You'll want to look at aliases
for that.
You can just use an FSRef, which will track the file even after it's
been moved. You have to use a little Carbon for this, but it's not
bad. Just use either FSPathMakeRef() or CFURLGetFSRef() to make the
FSRef before you move the file to the trash, and then use
FSRefMakePath() or CFURLCreateFromFSRef() to get the new path to the
file after you've trashed it.
An added benefit to this is that even if Apple ends up moving ~/.Trash
to some other location in a future version of OS X, this will still
work (as long as FSRefs still work on whatever new file system we get
moved to).
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