realbasic-nug
[Top] [All Lists]

Re: File Suggestions?

To: realbasic-nug@lists.realsoftware.com
Subject: Re: File Suggestions?
From: Sam Rowlands <rowlands@me.com>
Date: Wed, 29 Apr 2009 11:21:56 +0800
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <mailman.1.1240945205.15355.realbasic-nug@lists.realsoftware.com>
References: <mailman.1.1240945205.15355.realbasic-nug@lists.realsoftware.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
I personally have chosen IFF for such files. I'm sure there's a ton of reasons why one is better than the other, but from my experience I found IFF to create smaller files, to be faster and memory effcient. Huh? Well for instance I have some files which contain full size images and previews. If I use XML for these files, not only does all the data get loaded into memory, but it's twice as big because it's Base64. If I want just the preview, it takes up more memory and is slower... So using something like IFF, I can load what I need from the file into memory when I need it and because I don't have to Base64Decode it's quicker.

What Charles says is golden, make sure you include some format version tags. My files include several, one for the file structure and one for the data segments. This means I can change file structure whenever I need to or I can change data structure when I need to.

If you go down the binary route, make sure your code explicitly sets the endianess, otherwise your files will be incompatible across processors. binarystream.littleEndian = true

I personally use a structure like below.

4 bytes         String          Document Type
4 bytes         String          Application ID
2 bytes         Uint16          Version
<loop the following for as much data as you want to write>
4 bytes         String          Chunk ID
4 bytes         Uint32          Chunk Length
.....           .....           raw Chunk Data

Have a Great Week :)

Sam Rowlands




On Apr 29, 2009, at 3:00 AM, realbasic-nug-request@lists.realsoftware.com wrote:

Before I go ahead and code some binary version of my XML-based
document file I'd just like to ask if there's a right and wrong way to
save and read a binary file for this purpose having never really used
binary files before.


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>