Re: Correct way to tell if a path is to a .bundle?
I would read up on UTIs. Get the type of each file and see if it conforms to what you require. I have what I hope is a reasonably informative post here: http://www.mikeabdullah.net/utis_diagram/ Note how there is a com.apple.plugin type. If you're using a custom format for your plug-ins (and you should), make your app declare a com.foo.app.plugin type for them, which conforms to com.apple.plugin. On 25 Sep 2009, at 02:41, 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? TIA -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 24, 2009, at 9:51 PM, Rick Mann wrote: Thanks Jens. If I create a custom extension for my plugins (not even sure I can do that), will this still work? Yup, as long as you declare the extension properly in your Info.plist and indicate that it's a bundle. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On 9/25/09 8:12 AM, Jens Alfke said: Thanks Jens. If I create a custom extension for my plugins (not even sure I can do that), will this still work? Yup, as long as you declare the extension properly in your Info.plist and indicate that it's a bundle. Of course that requires that your Info.plist be present for Launch Services to consult. So while you should absolutely do as Jens says, you should additionally set the bundle bit for packages you create. See 'man SetFile'. SetFile -a B /path/to/package. Many apps fail to do this. Ever noticed that after a fresh OS install the Finder shows .xcodeproj packages as folders? That's why. -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 25, 2009, at 08:52:40, Sean McBride wrote: On 9/25/09 8:12 AM, Jens Alfke said: Thanks Jens. If I create a custom extension for my plugins (not even sure I can do that), will this still work? Yup, as long as you declare the extension properly in your Info.plist and indicate that it's a bundle. Of course that requires that your Info.plist be present for Launch Services to consult. So while you should absolutely do as Jens says, you should additionally set the bundle bit for packages you create. See 'man SetFile'. SetFile -a B /path/to/package. Many apps fail to do this. Ever noticed that after a fresh OS install the Finder shows .xcodeproj packages as folders? That's why. Thanks to you both for the details! -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 25, 2009, at 02:25:30, Mike Abdullah wrote: I would read up on UTIs. Get the type of each file and see if it conforms to what you require. I have what I hope is a reasonably informative post here: http://www.mikeabdullah.net/utis_diagram/ Note how there is a com.apple.plugin type. If you're using a custom format for your plug-ins (and you should), make your app declare a com.foo.app.plugin type for them, which conforms to com.apple.plugin. On Sep 25, 2009, at 08:12:41, Jens Alfke wrote: Yup, as long as you declare the extension properly in your Info.plist and indicate that it's a bundle. I confess, that after reading the docs, I'm not at all sure I'm doing things right. Here's what I've got (for my app called Foo): keyUTExportedTypeDeclarations/key array dict keyUTTypeDescription/key stringFoo PlugIn/string keyUTTypeConformsTo/key array stringcom.apple.plugin/string /array keyUTTypeIdentifier/key stringcom.latencyzero.foo.plugin/string keyUTTypeTagSpecification/key dict keypublic.filename-extension/key stringfooplugin/string /dict /dict /array keyCFBundleDocumentTypes/key array dict keyCFBundleTypeExtensions/key array string.fooplugin/string /array keyCFBundleTypeName/key stringPlugIn/string keyCFBundleTypeRole/key stringEditor/string keyLSItemContentTypes/key array stringcom.latencyzero.foo.plugin/string /array keyLSTypeIsPackage/key false/ keyNSPersistentStoreTypeKey/key stringXML/string /dict The CFBundleDocumentTypes was created using the Target-Properties- Document Types editor. Questions: 1) Do I need to put the UTI in my plugin's Info.plist, or just the app's, or both? 2) Is there a MIME type for my plugin? OSType? Class? 3) If I don't specify an icon, will it get the default plugin icon? 4) How do I indicate that the type is a bundle (Jens)? 5) Do I need to import UTIs anywhere? On Sep 25, 2009, at 08:52:40, Sean McBride wrote: Of course that requires that your Info.plist be present for Launch Services to consult. So while you should absolutely do as Jens says, you should additionally set the bundle bit for packages you create. See 'man SetFile'. SetFile -a B /path/to/package. I guess this would this be part of a script run after the plugin build? Thanks! -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 25, 2009, at 12:12 PM, Rick Mann wrote: keyLSTypeIsPackage/key false/ Shouldn't that be true, not false? —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 25, 2009, at 8:52 AM, Sean McBride wrote: So while you should absolutely do as Jens says, you should additionally set the bundle bit for packages you create. See 'man SetFile'. SetFile -a B /path/to/package. Sounds like good advice, but SetFile is a command-line tool, not an API. The actual API to set HFS flags is, I think, somewhere in CarbonCore/Files.h. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On 9/25/09 12:24 PM, Jens Alfke said: So while you should absolutely do as Jens says, you should additionally set the bundle bit for packages you create. See 'man SetFile'. SetFile -a B /path/to/package. Sounds like good advice, but SetFile is a command-line tool, not an API. The actual API to set HFS flags is, I think, somewhere in CarbonCore/Files.h. Yes. You can use the MoreFilesX sample code and do this: FSChangeFinderFlags (theFsRef, true, kHasBundle); -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
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. A file package is a directory that is presented as a single file to the user, while a bundle is a directory with a particular layout. For example, frameworks are bundles, but not packages. If you navigate to a .framework file in Finder, you will see that it looks like a folder. Likewise, you can take any directory and set the package bit, and it becomes a package. 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. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
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. A file package is a directory that is presented as a single file to the user, while a bundle is a directory with a particular layout. For example, frameworks are bundles, but not packages. If you navigate to a .framework file in Finder, you will see that it looks like a folder. Likewise, you can take any directory and set the package bit, and it becomes a package. 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. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
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/1123i-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/1123i-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 (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
Rick, You could also use: NSBundle pluginBundle = [NSBundle bundleWithPath: fullPath]; This will return an NSBundle object as your require or nil if fullPath does not identify an accessible bundle directory. So... if ( pluginBundle == nil ) ... then it is not a valid bundle. You will also want to create a protocol that the plugin's Principal class must conform to. So, a little snippet here for you that will load a valid bundle that conforms to MyPluginProtocol. - (id)loadBundleNamed:(NSString*)bundleName { Class exampleClass; id newInstance; NSString *bundlePath = [NSString stringWithFormat:@%@/ %...@.mypluginext,[self pluginDirectory],bundleName]; NSBundle *bundleToLoad = [NSBundle bundleWithPath:bundlePath]; if (exampleClass = [bundleToLoad principalClass]) { if ( [[bundleToLoad principalClass] conformsToProtocol:@protocol (MyPluginProtocol)] ) { newInstance = [[exampleClass alloc] initWithPlugInController: [PluginController sharedManager] bundle:[NSBundle mainBundle]]; // initWithPluginController is a method defined by MyPluginProtocol... so I am safe to use it return [newInstance autorelease]; } } return nil; } Brad Goss brad.g...@gmail.com On 2009-09-24, at 21:41 , 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? TIA -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/brad.goss%40gmail.com This email sent to brad.g...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
Rick, You could also use: NSBundle pluginBundle = [NSBundle bundleWithPath: fullPath]; This will return an NSBundle object as your require or nil if fullPath does not identify an accessible bundle directory. So... if ( pluginBundle == nil ) ... then it is not a valid bundle. This isn't actually true. For example, you can create a bundle with the path to a flat executable, and if that executable happens to have an Info.plist embedded inside it, you can access the values in the plist as if it were a full bundle. Likewise, if you point it at a random folder, you may still get a valid object back. I've got some rubycocoa scripts that take advantage of that very fact. Sorry. -BJ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Correct way to tell if a path is to a .bundle?
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? TIA -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
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:]. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com
Re: Correct way to tell if a path is to a .bundle?
On Sep 24, 2009, at 20:09:02, 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:]. Thanks Jens. If I create a custom extension for my plugins (not even sure I can do that), will this still work? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com