• 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: Opening the trash in the Finder?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening the trash in the Finder?


  • Subject: Re: Opening the trash in the Finder?
  • From: Michael McCracken <email@hidden>
  • Date: Tue, 28 May 2002 12:06:28 -0700

No, that is only for trashed documents that are on the same volume as
the home directory. Each volume has it's own trash directory. When the
finder shows the trash, it is actually showing a combination of all of these
directories.

Aha - this is indeed true. I missed that fact.

Okay, so although the applescript is the most elegant answer, here's a (hopefully*) total answer, because I was curious:

as mentioned before, the user's trash from the same volume as the home directory is stored in "~/.Trash/".

other volumes get mounted under /Volumes/, say a volume foo is /Volumes/foo/.
Then, its trashes are stored in /Volumes/foo/.Trashes/ - note the plural, because multiple users may have trashes from that volume.

Now, .Trashes can't be read by a user (permissions 0x333), but if they own a subdirectory, they can cd there and read its contents. If they've trashed something there, they do have a subdirectory, whose name is the user's uid. so, if my uid is 555, then my trash for volume foo is at /Volumes/foo/.Trashes/555/, which I can list the contents of.

So, a complete listing would require traversing everything in /Volumes/, then checking to see if .Trashes has a subdirectory `id`, and listing its contents.

*This might not be a total answer because I only have one drive on my system. I tested it by mounting a writable disk image and trashing something on that...

Now, that was fun, but tons of work, and might be fragile - i guess Apple might rename .Trashes/`id`/ - but they'll probably never change `tell aplication "Finder" open trash end tell`

cheers,
-Michael

PS, get current user's uid with the following POSIX call: (from `man uid`)
#include <unistd.h>
uid_t getuid(void);

(uid_t is a u_int32_t, which is defined as a C 'unsigned int' on ppc and i386.)


--
Michael McCracken
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Opening the trash in the Finder? (From: "Clark S. Cox III" <email@hidden>)

  • Prev by Date: Re: AESend
  • Next by Date: Re: AESend
  • Previous by thread: Re: Opening the trash in the Finder?
  • Next by thread: Re: Opening the Trash in the Finder?
  • Index(es):
    • Date
    • Thread