You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mz_zip_add_mem_to_archive_file_in_place() function seems to work great adding a new file into archive. However, if a file with the same name already exists in the archive, it creates a second entry with the same name instead of overwriting existing file in the archive. I think a better behavior would be:
Introduce MZ_ZIP_FLAG_ALLOW_OVERWRITE flag.
When mz_zip_add_mem_to_archive_file_in_place() is called with this flag, overwrite a file if it exists in the archive.
mz_zip_add_mem_to_archive_file_in_place without MZ_ZIP_FLAG_ALLOW_OVERWRITE flag, refuse to overwrite a file if it exists in the archive and return false.
Alternatively, it would be nice to add a high-level function to delete an existing file from the archive.
The text was updated successfully, but these errors were encountered:
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.
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.
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.
mz_zip_add_mem_to_archive_file_in_place() function seems to work great adding a new file into archive. However, if a file with the same name already exists in the archive, it creates a second entry with the same name instead of overwriting existing file in the archive. I think a better behavior would be:
Alternatively, it would be nice to add a high-level function to delete an existing file from the archive.
The text was updated successfully, but these errors were encountered: