Page 1 of 1

Writing a re-packer

Posted: Sun Aug 19, 2012 7:24 am
by finale00
I've been thinking about how to write a repacker but my design seems really inefficient.
I know the file table structure and the data is just compressed with zlib, so I was thinking of something like

-create stream for file table
-create stream for data
-for each file (recurse through folders), open the file, read it all in and compress it.
-write the file entry. filename/path is easy, size and compsize are easy. Offset is the size of the data stream.
-copy the compressed stream to the data stream
-repeat for all files

And then finally create a new file and write the table and data into it and there's my archive.

What's a different way to do it?