Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing files within archives in place #304

Closed
KOLANICH opened this issue Jun 20, 2022 · 1 comment
Closed

Replacing files within archives in place #304

KOLANICH opened this issue Jun 20, 2022 · 1 comment
Labels
enhancement Request a new feature. won't implement We won't implement this. If we receive usable patches, we will probably merge them.

Comments

@KOLANICH
Copy link

Description
There is a zip archive that can be large, GiBs. I need to modify a small metadata file within it. I need to do it without copying the whole archive. Modifying the file within the archive in-place is preferred and should be done this way, if it can be done. If it cannot be done I'm OK with small increase of archive size, i.e. if an additional entry is added. If I'm OK if the original file got corrupted in the case force majeures like program crashes, OS crashes, power losses.

Solution

  • Check the replacement data compressed size
  • If the size is exactly equal to the original compressed size, just overwrite and recalculate CRC
  • If the replacement is smaller, if I understand right, sections don't have to follow each other immediately, since their offsets are stored in the directory, so we can just truncate the file by changing its compressed size field, can we?
  • If the replacement is larger, can we backup the directory, add a new local header, then append the backed up directory, and fix the data in it to point to the new local header?

Describe alternatives you've considered
No

@KOLANICH KOLANICH added the enhancement Request a new feature. label Jun 20, 2022
@dillof dillof added the won't implement We won't implement this. If we receive usable patches, we will probably merge them. label Jun 20, 2022
@dillof
Copy link
Member

dillof commented Jun 20, 2022

This is contrary to the main design goals of libzip.

@dillof dillof closed this as completed Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request a new feature. won't implement We won't implement this. If we receive usable patches, we will probably merge them.
Projects
None yet
Development

No branches or pull requests

2 participants