views:

906

answers:

6

I would like to create a file format for my app like Quake, OO, and MS Office 07 have.

Basically a uncompressed zip folder, or tar file.

I need this to be cross platform (mac and windows).

Can I do something via command prompt and bash?

+2  A: 

Zip is supported everywhere. If a container is all you need, than those are surely good options.

André Neves
I strongly agree with this answer. Take Java's jars, for example: it's very convenient that they're actually ZIP files. Red Hat's RPMs are cpio files. In both cases, it's something that can be opened from the command line, which means it's easier to understand and troubleshoot.
markrlindsey
Gzip is not a container format; it is a compression format, and it can only compress a single file or data stream.
Adam Rosenfield
+2  A: 

Have a look at the open source 7Zip compression format. For your specific needs, you can use it in an "Archive" mode, zero compression but very fast.

It provides a powerful SDK, LZMA, from the site:

"LZMA is the default and general compression method of 7z format in the 7-Zip program. LZMA provides a high compression ratio and very fast decompression, so it is very suitable for embedded applications. For example, it can be used for ROM (firmware) compressing.

The LZMA SDK provides the documentation, samples, header files, libraries, and tools you need to develop applications that use LZMA compression."

Ash
+3  A: 

If you want a single file that is portable to all platforms and which contain structured data, consider using sqlite. You'll get a full featured ACID compliant database that exists on disk as a single file.

There are libraries you can link against to directly access the file, and there is a command line tool you can use as well. No matter what language you are using, most likely there is support for it.

http://www.sqlite.org

Bryan Oakley
A: 

First thing you should ask yourself is, "Do I really need to make my own?"

Depending on what you want to use it for, you are probably better off using a common format and some pre-made libraries which already handle one of those formats very well.

Good places to start: http://www.destructor.de/libtar/index.htm (tar -- a the 'container' format) http://www.zlib.net/ (zlib -- a method of compressing data before or after you put it in the container)

If you still really think you need to make your own, I would suggest studying something very simple first, like tar's format:

http://en.wikipedia.org/wiki/Tar_(file_format) or http://schmidt.devlib.org/file-formats/tar-archive-file-format.html

shea241
+1  A: 

SQLite is great.

A single file, crossplatform, a tiny library, SQL access to data, transactions, the whole enchilada.

you can use transactions to guarantee consistent return points in case of crashing. check uses for sqlite, they specifically advocate using it as a data model layer for desktop applications.

also, there's a command-line tool to manually access the data.

Javier
A: 

Instead of making a format, I'd just decide on a convention. One or more named files within the container have the metadata you need to access the rest of the files, and know what to do with them. The container itself, though, should just be some ubiquitous format, such as zip. No need to reinvent the wheel, here.

Brian Mitchell