Skip to content

Add Cabinet::all_files, method to extract all files in an archive sequentially and efficiently#34

Merged
mdsteele merged 2 commits intomdsteele:masterfrom
spoj:dev-iter
Jul 16, 2025
Merged

Add Cabinet::all_files, method to extract all files in an archive sequentially and efficiently#34
mdsteele merged 2 commits intomdsteele:masterfrom
spoj:dev-iter

Conversation

@spoj
Copy link
Copy Markdown
Contributor

@spoj spoj commented Jul 14, 2025

Currently, there is no method to retrieve all files in the cabinet. Library users who want to extract all files need to iterate using Cabinet::read_file, which throws away bytes up to where the target file is located in the decompressed stream, which is inefficient.

This PR adds a new method Cabinet::all_files that returns an AllFiles struct. When library user repeatedly calls next_file method on it, it yields tuples of (file_entry, reader) for each file in the cabinet.

fixes #33
fixes #24

Currently, there is no method to retrieve all files in the cabinet. Library users who want to extract all files need to iterate using Cabinet::read_file, which throws away bytes up to where the target file is located in the decompressed stream, which is inefficient.

This commit adds a new method Cabinet::all_files() that returns an AllFiles struct. When library user repeatedly calls next_file method on it, it yields tuples of (file_entry, reader) for each file in the cabinet.
@mdsteele
Copy link
Copy Markdown
Owner

Thanks, this seems reasonable. Just need to make sure cargo fmt and cargo clippy are happy.

@spoj
Copy link
Copy Markdown
Contributor Author

spoj commented Jul 16, 2025

Thank you. Fixed fmt and lints in latest commit. Took the liberty to to fix a couple lints that came up in ctype.rs and cabinet.rs that are not strictly related to this feat. Hope that's fine with you.

@mdsteele mdsteele merged commit 74dfdd7 into mdsteele:master Jul 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reuse folder reader across multiple files API Refactoring

2 participants