expose callback-based reader to stream archives from a custom source
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with the public reader API and the reader initialization paths in zip.c, then trace how mz_zip_archive.m_pRead and m_pIO_opaque are set and used. The issue proposes a callback signature and an additional open method, but names no files or tests; identify the public header and relevant tests before estimating the change. Done means callers can read an archive through their callback without keeping the full compressed archive in memory.
Written by the indexing model from the issue text.
Description
The public reader API forces a choice between reading from a path/FILE* or copying the entire compressed archive into RAM. There is no way to open an archive for reading backed by a custom data source (a caller-provided read callback). I'd like a public entry point that lets miniz pull compressed bytes on demand through my own callback.
I'm integrating zip into an engine that abstracts all I/O behind its own stream interface (not FILE*, and not necessarily a real filesystem path - resources can live inside other containers). Today my only option is:
zip_stream_open(buf, size, 0, 'r'); // requires the full archive in memory
which keeps the whole compressed archive resident for the archive's entire lifetime. For large archives this is a significant and unnecessary memory cost.
miniz already streams internally - mz_zip_reader_init* only parses the central directory up front, and entry data is pulled on demand via mz_zip_archive.m_pRead / m_pIO_opaque in 64 KB chunks. But because struct zip_t / mz_zip_archive are opaque outside zip.c, callers can't set m_pRead themselves. The streaming machinery exists; it just isn't exposed.
A read callback with the same shape as mz_file_read_func could be added:
typedef size_t (*zip_read_callback_t)(void *opaque, uint64_t offset,
void *buf, size_t n);
and wired into an additional _open method.
- Dominant language
- C
- Stars
- 1.6k
- Forks
- 308
- Avg merge
- 14h 22m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kuba--/zip
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug game: 01008BA02525A000 ios
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
area/ysql kind/bug priority/medium status/awaiting-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
yugabyte/yugabyte-db#37523 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
ly05010419/MacNativeGames#2079 ·
Maintainers usually reply within 1 day