8000 Feature request: Add support for writing raw entries like in 1.2 · Issue #217 · zlib-ng/minizip-ng · GitHub
[go: up one dir, main page]

Skip to content

Feature request: Add support for writing raw entries like in 1.2 #217

Closed

Description

@chenxiaolong

It seems that minizip 2.0+ no longer has the ability to write raw (pre-compressed) entries to a zip file. My main use case is copying files from one zip file to another, making changes to certain entries in the process. With minizip 1.2, It was possible to directly copy the compressed data from one file to the other to avoid the CPU overhead of decompression + recompression. This was done by passing 1 for the raw parameter in the unzOpenCurrentFile2 and zipOpenNewFileInZip2_64 functions.

Are there plans for implementing this in minizip 2.0 as well?

EDIT: For reference, this is an example of the raw entry copy I was doing before: https://github.com/chenxiaolong/DualBootPatcher/blob/f561b2d9d60ca793ab0056c74d603689972eaf1b/libmbpatcher/src/private/miniziputils.cpp#L353-L461

Activity

  1. nmoinvaz commented on Jan 2, 2018

    @nmoinvaz
    Member

    I believe mz_zip_entry_read_open has a raw parameter and for mz_zip_entry_write_open, use 0 as the compress_level.

  2. chenxiaolong commented on Jan 2, 2018

    @chenxiaolong
    Author

    @nmoinvaz Thanks! I gave that a try but it seems to produce a zip that's much larger than the original.

    Sample code that copies compressed data from one zip to another: https://gist.github.com/chenxiaolong/bcbb0835182ef16a25f09db8d99e0619

    [minizip] ./a.out /tmp/foobar.zip /tmp/foobar.out.zip
    [minizip] ls -sh1 /tmp/foobar.*
    367M /tmp/foobar.out.zip
    224M /tmp/foobar.zip
    
  3. nmoinvaz commented on Jan 2, 2018

    @nmoinvaz
    Member

    I used the gist you created (thanks btw!) and tested it against some zips that I created with WinRAR and wasn't able to reproduce those results. I tested a zip with a single file and one with multiple files. Can you try and narrow down what might be the cause? If you delete the output file and try the test again, does it work then? Thanks.

  4. chenxiaolong commented on Jan 2, 2018

    @chenxiaolong
    Author

    Hmm, that's inter E45E esting. Maybe it's a Linux specific issue? I just tried extracting the original zip, packing it again with 7zip, and this time, minizip created a 9.9 GB file. It doesn't seem to matter if I delete the output file first or not.

    [minizip] ./a.out /tmp/foobar.7zip.zip /tmp/foobar.out.zip
    [minizip] ls -sh1 /tmp/foobar.*
    220M /tmp/foobar.7zip.zip
    9.9G /tmp/foobar.out.zip
    

    Not sure if it helps at all, but these are the zips I was testing with:

    Original: https://noobdev.io/github/minizip/217/foobar.zip
    Repacked with 7zip: https://noobdev.io/github/minizip/217/foobar.7zip.zip

  5. nmoinvaz commented on Jan 2, 2018

    @nmoinvaz
    Member

    Looks like it was a bug reading entries that are 0-byte. Should be fixed now. Thanks.

  6. chenxiaolong commented on Jan 2, 2018

    @chenxiaolong
    Author

    Thank you! It's looking good in my initial testing. I'll try a couple more things and then close this issue if everything works.

  7. chenxiaolong commented on Jan 3, 2018

    @chenxiaolong
    Author

    Everything is looking good with respect to copying raw entries now. Thanks again for fixing this.

  8. nmoinvaz commented on Jan 3, 2018

    @nmoinvaz
    Member

    Compression method 99 is used for AES encryption. Are you using encryption now?

  9. chenxiaolong commented on Jan 3, 2018

    @chenxiaolong
    Author

    Sorry, that was caused by my own mistake. I deleted the post. I accidentally built the library with -DHAVE_AES and my test program without that, so the structs did not match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedIssue or bug has been fixednew featureNew featurerawRaw file storage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0