• 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: How determine if file is in Trash, given Path or Alias
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Gwynne Raskind <email@hidden>
  • Date: Mon, 1 Jun 2009 17:53:26 -0400

On Jun 1, 2009, at 4:31 PM, Sean McBride wrote:
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'.


This is a perfect example of why I would never use GC: That is the most nonintuitive confusing behavior I have ever heard of. If I crashed in the middle of DetermineIfPathIsEnclosedByFolder() for that reason I would never guess that GC was responsible!

-- Gwynne

_______________________________________________

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: How determine if file is in Trash, given Path or Alias
      • From: Quincey Morris <email@hidden>
References: 
 >Re: How determine if file is in Trash, given Path or Alias (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: gcc parsing error?
  • Next by Date: re: SQL store, GC apps, "statement is still active" exception, setReturnsObjectsAsFaults:NO
  • Previous by thread: Re: How determine if file is in Trash, given Path or Alias
  • Next by thread: Re: How determine if file is in Trash, given Path or Alias
  • Index(es):
    • Date
    • Thread