File formats for multi-doc app: packages, single files or zipped alternatives
File formats for multi-doc app: packages, single files or zipped alternatives
- Subject: File formats for multi-doc app: packages, single files or zipped alternatives
- From: Keith Blount <email@hidden>
- Date: Sun, 17 May 2009 10:20:16 -0700 (PDT)
Hi,
I’m working on version 2 of my software at the moment, and in so doing and am looking into the possibility of a better file format and was wondering if I am missing something. Currently, my program uses a file package format i.e. a folder that looks like a single file, but the contents of which you can see in the Finder by selecting “Show Package Contents”). The reason I took the file package route is that it allows me only to read files from the package as and when necessary. One of my app’s files can contain lots of different types of data - movie files, sound files, text files, PDF documents and more - but it only ever displays one or two of these documents at a time. Thus, under the current set-up, whenever a file is needed, the program can just look inside the package and read only the file required. If all of this data was stored in a single file rather than a file package, the whole file - containing potentially hundreds of documents, some
large in size - would get loaded into memory unnecessarily, and slow everything down. (The other advantage of the file package format is that it is transparent to the user, and the user knows that even if one file gets corrupted, the others in the package should be safe.)
However, there are some issues with the package format, chief among them synchronisation; much synchronisation software just doesn’t play nicely with file packages, and some users not au fait with the package format have had files corrupted by synchronisation software. They have problems e-mailing files to each other (not all e-mail software allows them as attachments because they are interpreted as folders), sharing them across networks and suchlike too.
Anyway, my question is, is there a happy medium between the single file format and the file package? What solution do others use for files that contain multiple documents which could span to hundreds of megabytes and don’t all need to be in memory at once? What I was wondering is if it would be possible to use a zipped format instead. That is, to have my program zip up all of the necessary files - so that the zip replaces the package, a zip file being treated as one file in all the places that count - and then only to read from the zip file the necessary files, and to write back into it files that have changed. Is this possible? That is, is it possible to extract a file from a zip archive into memory, without extracting it to disk first? And is it possible to place data into an existing zip archive without writing the data to disk as a file first, and without having to recreate the entire zip file? (I am sure it is possible, so, to put it another way:
is it possible with the tools readily available? Currently when I create zip files from my app - for its backup feature - I use NSTask to invoke -zip on the commandline, usr/bin/zip.) My app auto-saves, so the solution needs to be fast, too.
Thanks in advance for any thoughts.
All the best,
Keith
_______________________________________________
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