• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trashing files and undo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Trashing files and undo
      • From: Ruotger Skupin <email@hidden>
References: 
 >Re: Trashing files and undo (From: Gregory Weston <email@hidden>)

  • Prev by Date: Re: Trashing files and undo
  • Next by Date: Re: Trashing files and undo
  • Previous by thread: Re: Trashing files and undo
  • Next by thread: Re: Trashing files and undo
  • Index(es):
    • Date
    • Thread