by Dan East » May 24, 2001 @ 11:09am
The pak format is pretty straightforward. There's a table at the beginning of the file containing an entry for each file, with it's name, filesize, and offset into the pak. Extracting is just a matter of seeking in by the offset and reading filesize bytes. I just use the gzip algorithms for reading if the pak has a .gz extension. The problem is that the pak / gz combo is very slow. Seeking in a gzipped file means reading / decompressing. If you seek to a location before the current file pointer, then gzip resets back to beginning and decompresses up to the desired seek location. This makes for very poor random file access. Terry Whiterod, of PocketHexen fame, came up with a much more effecient technique of gzipping pak / wad files. He offered me more information on his technique , but he never responded to my emails.<br>Zlib decompressing is really not that slow. It is just not cool when various segments of the file have to be decompressed hundreds of times over due to file seeking. If I never hear back from Terry I will pursue my own optimized gz/pak routines in a month or so.<br><br>It took some minor tweaking for the zlib source to build for Pocket PC, so you ought to just grab the zlib files out of the PQ source.<br><br>Dan East