• 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: 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


  • Follow-Ups:
    • Re: How determine if file is in Trash, given Path or Alias
      • From: Martin Wierschin <email@hidden>
    • Re: How determine if file is in Trash, given Path or Alias
      • From: "Sean McBride" <email@hidden>
    • Re: How determine if file is in Trash, given Path or Alias
      • From: Kyle Sluder <email@hidden>
References: 
 >How determine if file is in Trash, given Path or Alias (From: Jerry Krinock <email@hidden>)
 >Re: How determine if file is in Trash, given Path or Alias (From: "Adam R. Maxwell" <email@hidden>)

  • Prev by Date: Creating, Constructing and Managing Dynamic (Sub)Views
  • Next by Date: Re: How determine if file is in Trash, given Path or Alias
  • 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