2

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.

4
  • Do you mean "bundle"?
    – nobody
    Oct 16, 2014 at 20:40
  • No ! I am just traversing a directory in OSX App and what I need is to distinguish between directories and packages. I want to know that a file enumerated is a package or not. Oct 16, 2014 at 20:41
  • @Kevin I had that solution before posting this question that why not if NSURLIsDirectoryKey returns true check that whether the file has an extension like .something then that means its a package but what about folders named in mac like com.something.something etc ? Oct 16, 2014 at 20:50
  • 1
    NSWorkspace provides a high level interface for that kind of thing. LaunchServices provides the low level.
    – CodaFi
    Oct 16, 2014 at 21:05

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.