Original Post
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?