Re: FS item in trash
Re: FS item in trash
- Subject: Re: FS item in trash
- From: gweston <email@hidden>
- Date: Tue, 02 Oct 2012 01:03:55 +0000 (GMT)
Is there an API (carbon or cocoa) to determine if an item is in the trash?
NSFileManager, NSFileHandle and carbon Files.h do not have anything.
Or do I just do a path search looking for ".trash"?
You definitely do *not* do that. The name and location of the trash directory is an implementation detail that you shouldn't and needn't rely on. It's not ".trash" regardless. To date, the location of the trash on the volume containing the user's home directory is ~/.Trash and the location on all other volumes that have a trash at all is /Volumes/mount_point/.Trashes/`id -u` but that could change without notice.
In recent OS versions, you can use NSFileManager to get the URLs for mounted volumes and then loop over them using:
NSURL* u = [fm URLForDirectory:NSTrashDirectory inDomain:NSUserDomainMask appropriateForURL:mountPointURL create:YES error:&error];
Note that if you pass NO for the create argument and the trash directory doesn't exist you'll get back nil which may or may not be useful for your needs.
_______________________________________________
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