Resource file algorithm

Started by
0 comments, last by Juicy 20 years, 11 months ago
I''ve noticed that there''s no information (at least on many keyword searches on google and gamedev) on resource files. They are integral to many games and make it a litle bit more tricky for others to steal the media from your game. I''ve basically used the .PAK file from quake 2 as a template for my own package file, but I''m having a wrestle with my own ideas on implementing add and delete to/from the resource file... Here''s my initial idea (which is not efficient in memory): Add file to PAK: 1. Load the header into memory (12 bytes) 2. Load the directory structure into memory (64 bytes per ''file'' in the PAK) as an array of dirs. 3. Store all of the binary data in a block of memory (up to many many Mb - potentially around 200 at worst case) 4. Add binary data to the huge block from the file to be added. 5. Create a new directory entry and tag that onto the array of dirs. 6. Write the file back to the filesystem in order (Header, Binary data, dirs collection). Removing from the PACK is obviously very similar, so I''ll not go into the algorithm. My question is, do I have to load the whole binary block into memory, since this is likely to be quite large? I *could* output each of the files to a temporary file in blocks, thus reducing the memory overhead, but the speed will probably decrease as a result. Your thoughts or suggestions?
I like pie! - weebl.
Oneiric - Another graphics engine in the works.
Advertisement
i''d just have the files saved in separate temp files, since that would be easiest. the speed issue wouldn''t be too important, since the resource file wouldn''t need to be compiled all that often. i have noticed that with huge ZIP archives, winzip creates temp files to handle this.

of course, you could get fancy, and check available memory to see if the external temp files are necessary, or if it will all fit in the memory.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

This topic is closed to new replies.

Advertisement