Thread: File Format
View Single Post
  #5 (permalink)  
Old 08-03-2007, 05:02 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
XML is common, and INI files are still used too. Honestly, it doesn't matter which one you use since they're both text. If the language has a specific facility for reading and parsing XML, it may be faster than using an INI file, though a language may also have built-in support for reading and parsing an INI file too. You could also use a binary file format, where the lengths of the "records" are varied in length. For example, you could have the equivalent of the following to store usernames (thinking about it like a hex editor):
'd' 'u' 'm' 'm' 'y' 00
'F' 's' 't' 00

You could also store the length, eliminating the need to check for a null terminator and also allowing you to have more control because you would not be reading an unknown number of bytes until you hit a null terminator, which may in fact be absent if improperly coded. The downside to this method is that you would need to ensure that it is saved properly, which would most likely require a hex editor if you don't have one already.

__________________
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."
-- Bjarne Stroustrup, creator of what is now known as C++
For more quotes by Bjarne Stroustrup, check out http://www.research.att.com/~bs/bs_faq.html#really-say-that.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to rpgfan3233 For This Useful Post:
HelloWorld (08-03-2007), TeraTask (08-03-2007)