Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Newbie question: Can documents be bundles?

Newbie question: Can documents be bundles?
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2000
Location: Oslo, Norway
Status: Offline
Reply With Quote
Jan 26, 2002, 07:48 AM
 
I've got a question, which might sound silly or even naive. Coming from a traditional Unix (and Java/Perl) background than OS X/NeXTStep, the concepts of bundles are not quite clear to me yet.

Anyway, I have an application that saves a lot of small files (they're individual tables in a database). Is it possible to use the Bundle mechanism to make all of these files appear as one single file (database) in the Finder? When I double click the icon, my application should start.

I've tried to understand Apples documentation on this, and the closest thing to what I'm imagining is perhaps loadable bundles. But I'm not sure if these loadable bundles has to include executable code or not.

Scotty.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jan 26, 2002, 10:24 AM
 
Originally posted by scotty:
<STRONG>I've got a question, which might sound silly or even naive. Coming from a traditional Unix (and Java/Perl) background than OS X/NeXTStep, the concepts of bundles are not quite clear to me yet.

Anyway, I have an application that saves a lot of small files (they're individual tables in a database). Is it possible to use the Bundle mechanism to make all of these files appear as one single file (database) in the Finder?</STRONG>
Apparently so. I've personally never tried, but I know that documents can be bundles. Just look at any .pbproj file.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 26, 2002, 11:34 AM
 
Yes, it involves something to do with NSFileWrapper and flags in your Info.plist. I'm sure you'll be able to figure it out
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Jan 26, 2002, 06:04 PM
 
Yeah, it's possible. Just look at files you make with TextEdit that hav eimage: they are saved as .rtfd files and they are really a folder with an rtf file and a folder full of images below it.

Not sure how, though

F-bacher
     
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status: Offline
Reply With Quote
Jan 28, 2002, 03:50 AM
 
Yes, it definitely is possible. Personally, i think more programs should be doing it. When you get a sensible idea how, tell us!

Bonus Question for 150 points: is it possible to set type/creator codes on a folder, or would a bundle have to use a .something file extension?
All words are lies. Including these ones.
     
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Jan 30, 2002, 03:20 PM
 
Although if you have documents like this you then have the problems of cross-platform. It would be nice if there was something *like* bundles, but stored in some format like a .zip file.
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Jan 30, 2002, 07:17 PM
 
Official Apple lingo:
  • A package is a folder which appears to the user as a single file. This includes applications, loadable plugin bundles, Interface Builder documents (.nib), RTFD documents, and others. Document packages are sometimes also called file wrappers, as they're often created and manipulated using the NSFileWrapper API.
  • A bundle is a folder full of stuff which conforms to the convention of the CFBundle/NSBundle API. It may or may not also be a package: Applications and loadable bundles are both bundles and packages, but frameworks are bundles but not packages, as you can browse into them in the Finder. Document packages like NIB and RTFD files are not bundles.
Kind of confusing, but that what Apple calls 'em, and why it might be hard to find the documentation you're looking for.

If you want to have a package/filewrapper document type, you'll need to set LSTypeIsPackage to YES in the CFBundleDocumentTypes entry for htat type in your Info.plist. You can create and manipulate packages using any API that lets you create and manipulate files and folders; however, it's probably easiest to use NSFileWrapper in Cocoa (and/or the NSDocument methods for file wrappers).
Rick Roe
icons.cx | weblog
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jan 31, 2002, 12:01 PM
 
Originally posted by sadie:
<STRONG>Yes, it definitely is possible. Personally, i think more programs should be doing it. When you get a sensible idea how, tell us!

Bonus Question for 150 points: is it possible to set type/creator codes on a folder, or would a bundle have to use a .something file extension?</STRONG>
Although you can't actually set type/creator on a folder, there's a file inside the bundle (Contents/PkgInfo) which can contain T&C information for the bundle as a whole. So strictly speaking, an extension shouldn't be necessary.
Although if you have documents like this you then have the problems of cross-platform. It would be nice if there was something *like* bundles, but stored in some format like a .zip file.
There is no cross-platform issue. Other platforms will just see a folder with a bunch of files in it, but the files will still work. And because they don't depend on their metadata, a bundle copied onto a Windows machine, then back to a Mac, should still work. That's one of the cool things about them (though I still say metadata is a superior solution for individual files).
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2