Re: Trashing files and undo
Re: Trashing files and undo
- Subject: Re: Trashing files and undo
- From: "Sean McBride" <email@hidden>
- Date: Fri, 11 Jul 2008 11:54:47 -0400
- Organization: Rogue Research
On 7/11/08 10:49 AM, glenn andreas said:
>
>On Jul 11, 2008, at 10:44 AM, Gregory Weston wrote:
>
>> Ruotger Skupin wrote:
>>
>>> my app trashes files with -[NSWorkspace
>>> performFileOperation:source:destination:files:tag:] and
>>> NSWorkspaceRecycleOperation. This works flawlessly but users want
>>> undo.
>>>
>>> NSWorkspace does not seem to allow undoing said file operation (or
>>> any
>>> file operation for that matter). Correct me if I'm wrong.
>>>
>>> So I might have to figure out where the trash directory for a given
>>> volume/user/file etc is and move it myself. Is there an easy way to
>>> find that out?
>>
>> 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.
>
>If you use aliases (and due to the renaming issues, you really
>should), you won't need to worry about where the trash is located,
>since you'd just resolve where the file currently is (which just
>happens to be the correct trash folder for that volume/user).
Unless of course between trashing the file and trying to undo the
trashing, a file of the same name as the trashed item is put in its old
location. 1) that would cause the wrong alias resolution (since aliases
resolve by path first) and 2) it would make restoring the trashed file tricky.
I think it is very hard to get all the edge cases. Maybe if you script
the finder to trash the file, then the finder's undo would be available.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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