I have tried that but it isn't reasonable since the files that I compress
are xml, and its pain to separate them for parsing.
Lets say you have 3 files you want to compress and archive into the same
file.
Then first compress the first file, write the compressed data into your
archive file and save the amout of bytes the compressed data uses in some
collection. Then do the same for the next 2 files. Now that all data is
compressed and written to the archive, you'll need to write a TOC where you
can use the saved sizes to calculate wich position a file starts and ends
at, and so on. When you created the TOC and written it to the file, you can
finally write the size of the TOC in the last bytes in the file, and that
way you will know where the TOC starts when you need to uncompress one or
more files.
Or to make it more easy to start with you can create a seperate file for the
TOC.
Compress files, save sizes, start and stop position in file and dump them
all into one file. Then in a seperate file you could in text mode create a
TOC with a syntax like:
filename startpos endpos
then file size will be (endpos - startpos).
When you want to uncompress you will read the TOC file.
Create a new file with the filename from the toc file, "fast forward" the
file to startpos, and start reading and decompressing until you reach
endpos.
When that is working for you then you could try to merge a toc into the
compressed archive.
//eric