Re: Trashing files and undo
Re: Trashing files and undo
- Subject: Re: Trashing files and undo
- From: Ruotger Skupin <email@hidden>
- Date: Sat, 12 Jul 2008 09:16:39 +0200
Hi Charles,
let me make sure I understand that.
I get the FSRef and the original path of the file and keep hold of the
information before trashing it with performFileOperation::::. When I
want it back, I resolve the FSRef and move it back to original location.
Ruotger
Am 11.07.2008 um 17:54 schrieb Charles Srstka:
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
_______________________________________________
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