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: "Sean McBride" <email@hidden>
- Date: Mon, 1 Jun 2009 16:31:09 -0400
- Organization: Rogue Research Inc.
On 5/28/09 3:49 PM, Martin Wierschin said:
>This is a nice trick, I wasn't aware of that function, thanks.
>Perhaps a minor improvement (one call instead of two):
>
>- (BOOL) isTrashedFileAtPath:(NSString*)path
>{
> Boolean inTrash = false;
> const UInt8* utfPath = (UInt8*)[path UTF8String];
> OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk,
>kTrashFolderType, utfPath, false, &inTrash);
> return (noErr == err) ? (true == inTrash) : NO;
>}
>
>Probably it does the same thing behind the scenes, but why not.
For the archives: 2 more problems:
a) use fileSystemRepresentation not UTF8String.
b) with GC, 'path' may be collected before
DetermineIfPathIsEnclosedByFolder() is finished with utfPath. So best
to add a [path self] just before the 'return'.
--
____________________________________________________________
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