Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zipster

Compaction, not Compression

This topic is 6645 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically, I''m trying to figure out a way to merge several files into one file. I don''t really want any compression, just the files be merged into one file for ease. I was thinking of opening each file seperatly, and then writing them to one big file, with header information and stuff, but then I was wondering just how i would do that. I have some ideas, but any suggestions would be apreciated. Then, would I have to create some sort of internal file structure? I dunno... I really could just use the PAk format i guess, but I don''t know how that works, or if there is any copyright on it. ======================================= A man with no head is still a man. A head with no man is plain freaky.

Share this post


Link to post
Share on other sites
Advertisement
There''s an article right here on Gamedev about that, it''s called "Resource files explained". I''ve got some code that merges several files into one file (it''s messy though ), let me know if you want it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Wihtout thinking twice (it''s late) , I''d say to just concat all the file in memory(assuming they fit) keeping track of the length and starting location of each file. Then write the index to the beginning of the file followed by the data. The index I''m thinking about would be something like:


unsigned long NumberOfIndexRecords;
unsigned long FileStart
unsigned long FileLength
... repeat last two for number of records


In fact the Record Start\Length in an array of structs would be good. That way you can just dump the array straight to disk.

For loading, first 4 bytes represents number of index records, then just multiply this number by sizeof(FileIndexStruct), read that in and you have a map to all the files. Then you can either load them all in or load in the ones you want individually(as you now have their offset(which is the total size of the index + 4(as in + the size of the numrecords).

There are probably more advanced methods but this is sort of how I do my network message packing...

Would someone explain why you might want to do this? In creating a game I would have expected leaving the files in the original format would make re-editing much easier.

..

gimp

(Oh, I forgot, you might want to store the original file name in there too. This become slightly more difficult but not by much.)

(Oh, again, you might also have a look around for the Q2 pak file format. Conforming to their spec would mean you can automatically use all the q2 pak explorer utilities etc. Besides that you''ll only have to work out the loader as the explorers can be used to create the .pak files. Make sure to get an ''old'' pak file format, the new one is a just a zip file)

Share this post


Link to post
Share on other sites
I want to be organized, remember. I''m really trying to avoid PAK format because I don''t want people looking around my PAK files and changing things.

=======================================
A man with no head is still a man.
A head with no man is plain freaky.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Zipster

I''m really trying to avoid PAK format because I don''t want people looking around my PAK files and changing things.

quote]

Good luck. Even if you encrypt the file, your game will just sit there and decrypt it under the watchful gaze of someone in a debugger.




Share this post


Link to post
Share on other sites
Well, my game isn''t gonna be so impressive that a hacker would really give a hoot. I just don''t want an everyday user to go experementing.

=======================================
A man with no head is still a man.
A head with no man is plain freaky.

Share this post


Link to post
Share on other sites
Hi,

i''ve written a resource-management and a resource-builder myself.
You should have a look at the way doom saved it''s resources. The .wad files was just a bunch of files with an appended TOC (Table of contents). More information about .wad structure is in the unofficial doom faq! (if you don''t find it anywhere in the net, e-mail me!)

Stony

~~~
A bus-station is where a bus stops.
A train station is where a train stops.
On my desktop there is a workstation...

Share this post


Link to post
Share on other sites
.wad files just held the map data, right? Because I was looking for the midi files for the music from Doom2. But everything is appended to the executable.

=======================================
A man with no head is still a man.
A head with no man is plain freaky.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hehe, never overlook the obvious...

copy filea + fileb dest

Good ol'' DOS

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!