Re: Correct way to tell if a path is to a .bundle?
Re: Correct way to tell if a path is to a .bundle?
- Subject: Re: Correct way to tell if a path is to a .bundle?
- From: Gregory Weston <email@hidden>
- Date: Fri, 25 Sep 2009 23:35:24 -0400
Rick Mann wrote:
On Sep 25, 2009, at 17:15:45, Peter Ammon wrote:
On Sep 24, 2009, at 8:09 PM, Jens Alfke wrote:
On Sep 24, 2009, at 6:41 PM, Rick Mann wrote:
I'm scanning a directory for plugins for my app. Given a path,
what's the right way to tell if it's a path to a bundle?
-[NSWorkspace isFilePackageAtPath:].
Actually, bundles are often packages, and vice versa, but you can be
either without the other.
...
The usual way is to just try loading the URL as a bundle, and see if
you succeed. You could also define a particular extension for your
plugin type, and look for files of that extension, with the
assistance of CFBundleCreateBundlesFromDirectory.
Unfortunately, I don't think CFBundleCreateBundlesFromDirectory() will
work for me. It creates CFBundleRefs, not NSBundles, and it loads
them, which I want to avoid if possible.
I think I just have to check the filenames' extensions as I iterate
them.
I would think the answer to "how do I tell if a path is to a bundle"
has to be implicit in what it means for something to be a bundle.
<http://developer.apple.com/mac/library/DOCUMENTATION/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html#//apple_ref/doc/uid/10000123i-CH100-SW1
>
"A bundle is a directory with a standardized hierarchical structure
that holds executable code and the resources used by that code. ...
The exact structure of a bundle depends on whether you are creating an
application, framework, or plug-in. It also depends on other factors
such as the target platform and the type of plug-in."
Further down: "Custom plug-ins are plug-ins you define for your own
purposes; see 'Anatomy of a Loadable Bundle.'"
Which links to <http://developer.apple.com/mac/library/DOCUMENTATION/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW32
>
"At the top-level of the bundle is a single Contents directory. Inside
this directory are several subdirectories for storing executable code
and resources. The Contents directory also contains the bundle’s
Info.plist file with information about the bundle’s configuration."
So, without testing it, it seems like a first stab would be:
It's a directory, and the name includes an extension.
The directory contents comprise a single directory named Contents.
That subdirectory contains an Info.plist file and a directory named
MacOS.
The MacOS directory contains a binary identified by the
CFBundleExecutable key of the Info.plist.
_______________________________________________
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