-1

I have written a zip class that uses functions and code from miniz to: Open an archive, Close an archive, Open a file in the archive, Close a file in the archive, and write to the currently open file in the archive.

Currently opening a file in an archive overwrites it if it already exists. I would like to know if it is possible to APPEND to a file within a zip archive that has already been closed?

I want to say that it is possible but I would have to edit all offsets in each of the other file's internal states and within the central directory. If it is possible - is this the right path to look in to?

Note: I deal with large files so decompressing and compressing again is not ideal and neither is doing any copying of files. I would just like to "open" a file in the zip archive to continue writing compressed data to it.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Will M
  • 19
  • 2
  • Since in a zip file appending something to the data and then zipping doesn't result in appending something to the file, but rather in changing it in multiple plaes, I figure that's impossible. Zipping is possible due to correlations between different data elements, so is non-local with respect to a certain data element. – Jacques de Hooge Aug 03 '16 at 18:52

1 Answers1

1

I would just like to "open" a file in the zip archive to continue writing compressed data to it.

Compressed files aren't working like a file system or folder, where you could change individual files. They keep e.g. check sums, that need to apply for the whole archive.

So no, you can't do such inplace, but have to unpack the compressed file, apply your changes and compress everything again.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • If I could get the file stats from the archive such as its local directory header, offset into the archive, etc... couldn't I just edit that information and write compressed data as if I were writing a new file into the archive? – Will M Aug 03 '16 at 20:33
  • @WillM Well, if your compression library API provides such featur, go forward with it. – πάντα ῥεῖ Aug 03 '16 at 20:35