Giter VIP home page Giter VIP logo

Comments (3)

rebirth123 avatar rebirth123 commented on June 30, 2024 1

I just started using this version of miniz and have also discovered this problem. During my tests I called add to zip file (with the same "pArchive_name") a number of times. mz_zip_reader_get_num_files even includes the duplicates into the count. This doesn't feel like it's the proper behaviour. "_in_place" suggests it should overwrite if it doesn't exist.

I'm trying to figure out a workaround, but like I've said, I've only been using it for a couple of hours and only to create, add and read files from and to zip archives. A hint would be welcomed.

from miniz.

rebirth123 avatar rebirth123 commented on June 30, 2024 1

I got around it the hard way:

Try and open the zip file with "mz_zip_reader_init_file". If successful read the archive names and compare them to the new archive names to be added. If no duplicate found add them to a list of indices to keep. Create a write zip with "mz_zip_writer_init_file"using a temporary filename and clone the indices to keep from the read zip into the write_zip using "mz_zip_writer_add_from_zip_reader". When done, add the new data using either "mz_zip_writer_add_file" or "mz_zip_writer_add_mem"(if working from memory). Finally call "mz_zip_writer_finalize_archive" and then call mz_zip_writer_end and mz_zip_reader_end.

Then just delete the original zip file and rename the new zip file.

from miniz.

ell1e avatar ell1e commented on June 30, 2024

For what it's worth, I vaguely remember having similar issues with Python. And since stuff shifts around when replacing entries, I assume solving it on miniz's side might not be that easy either. So maybe the best solution is to just rewrite changing archives like @rebirth123 did.

from miniz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.