Search code examples
objective-cmacosnsfilemanager

How do to identify that a file is a package?


I have used NSDirectoryEnumerator to enumerate files in a Cocoa App (OSX). I am able to identify many properties of files e.g that a file is a directory or not, its creation date,modification date etc using NSURL File Property Keys. What I am not able to identify is that whether a file is a package or not ? I have gone through every bit of NSURL,NSFileManager reference but I have not been able to find a way. Am I missing something ?

I have also seen that for a file that is a package NSURLIsDirectoryKey returns true. But in my case I still want to categorise directories and packages separately.


Solution

  • I found the method in NSWorkspace class. wonder why it was not included in NSURL File Property Keys

    - (BOOL)isFilePackageAtPath:(NSString *)fullPath
    

    Return Value YES if the path identifies a file package; otherwise, NO if the path does not exist, is not a directory, or is not a file package.