Re: How determine if file is in Trash, given Path or Alias
Re: How determine if file is in Trash, given Path or Alias
- Subject: Re: How determine if file is in Trash, given Path or Alias
- From: Jerry Krinock <email@hidden>
- Date: Wed, 27 May 2009 22:04:49 -0700
Thanks, Kiel and Adam. FSDetermineIfRefIsEnclosedByFolder() has the
advantage over IdentifyFolder(parent) of working for items that are
buried in folders that are in the trash, but strangely it gives a -35
nsvErr "no such volume" error if the item is not in the trash. I just
ignore all the errors anyhow, since, for example, if a file is "not
found", it's obviously "not in the trash".
At first I thought these FS functions were in Carbon, but the docs say
that they are in CoreServices, so I guess this is OK for the 64-bit
future.
BOOL isInTrash(NSString* path) {
FSRef fsRef;
Boolean result = false ;
OSStatus err = FSPathMakeRef(
(UInt8*)[path UTF8String],
&fsRef,
NULL) ;
if (err == noErr) {
FolderType folderType ;
FSDetermineIfRefIsEnclosedByFolder (
kOnAppropriateDisk,
kTrashFolderType,
&fsRef,
&result
) ;
}
return (result == true) ;
}
_______________________________________________
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