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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to