richgel999 / miniz

miniz: Single C source file zlib-replacement library, originally from code.google.com/p/miniz
MIT License
2.2k stars 322 forks source link

[question] Reading files with mmap for compression level "no compression" #320

Open vadimkantorov opened 2 months ago

vadimkantorov commented 2 months ago

Hi!

Am I right that for zip files with no compression, reading can be done simply via mmap after calculating offset and byte count?

Can miniz help in reading from such ZIPs: i.e. parsing the ZIP file tree and providing a requested file offset and byte size?

There is the mz_zip_archive_file_stat structure https://github.com/richgel999/miniz/blob/8714fd3cd8788eb18304200607247926f9728d1f/miniz_zip.h#L22-L77, but I need help figuring out how to get a byte offset from the ZIP file beginning from an instance of this structure (and if it's possible currently).

Or maybe this other mz_zip_reader_extract_iter_state structure could be used for this? https://github.com/richgel999/miniz/blob/8714fd3cd8788eb18304200607247926f9728d1f/miniz_zip.h#L186-L208

Or is compression level "zero" not supported by miniz decompression routines? I unfortunately can't understand where in code the MZ_NO_COMPRESSION decompression case is treated :(

If it's not possible, adding such a field for "no compression" files would be nice for mmap-based file readers.

Thanks!