• 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: Testing if a folder is a bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing if a folder is a bundle


  • Subject: Re: Testing if a folder is a bundle
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 27 Aug 2001 08:36:31 -0700

On Sunday, August 26, 2001, at 10:39 AM, Chris Boot wrote:

I've been trying to programmatically test whether a certain folder is a
bundle, with no success. I've tried creating a CFBundleRef from an NSURL
(I'm writing a Cocoa app) cast to a CFURLRef (this is valid), but
CFBundleCreate just happily creates bundles for folders which quite
obviously are NOT bundles. I've also tried getting the folder's finder
flags and testing for the bundle bit (which works on Mac OS 9, AFAIK), but
that doesn't work.

Is there a way of programmatically telling whether a folder should be
treated like a file? How does the Finder do it?

We try to distinguish between the notion of a "bundle" and that of a "package". A package is a folder that is presented to the user as a single object. A bundle is a folder that is structured in one of the ways that CFBundle/NSBundle can interpret. The notions are distinct: for example, a nib is a package but not (except trivially) a bundle; a framework is a bundle but not a package; a packaged application is both.

CFBundle knows nothing about presentation to the user, and so it is not in the business of recognizing packages. Its job is to look up files within bundles, and it does its best to do so even if the folder you give it is not really bundle-structured; most of the bundle structures are optional.

The place to look for recognizing packages is in another system layer entirely--Launch Services, or some of its Cocoa equivalents within NSWorkspace. For example, from Cocoa you can use the NSWorkspace method isFilePackageAtPath:.

Douglas Davidson


  • Follow-Ups:
    • Re: Testing if a folder is a bundle
      • From: Chris Boot <email@hidden>
References: 
 >Testing if a folder is a bundle (From: Chris Boot <email@hidden>)

  • Prev by Date: Re: Getting keyDowns
  • Next by Date: Re: Finding keyboard state in Cocoa
  • Previous by thread: Re: Testing if a folder is a bundle
  • Next by thread: Re: Testing if a folder is a bundle
  • Index(es):
    • Date
    • Thread