 |
 |
Newbie question: Can documents be bundles?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2000
Location: Oslo, Norway
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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).
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
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!
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|