Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read only one file in the archive, without loading the data of the others #79

Closed
fabmazz opened this issue Sep 19, 2024 · 1 comment · Fixed by #80
Closed

Read only one file in the archive, without loading the data of the others #79

fabmazz opened this issue Sep 19, 2024 · 1 comment · Fixed by #80

Comments

@fabmazz
Copy link

fabmazz commented Sep 19, 2024

Hi,
Very nice library, great alternative to ZipFile!

From the examples posted, I see that you have to read the entire zip archive contents before decompressing it.
I was wondering if it would be possible to implement a way to just read the archive file list, and read one file at a time using a stream-like interface. That way, if I have a rather big zip archive with many files, I can load only the ones that I want, without wasting time and memory for the others.

Thanks a lot!

@nhz2
Copy link
Member

nhz2 commented Sep 19, 2024

Thank you for the feedback. Yes this is possible using Mmap.jl if you are reading a file.

using Mmap: mmap
using ZipArchives
archive = ZipReader(mmap(open("Downloads/ZipArchives.jl-main.zip")))
zip_openentry(archive, "ZipArchives.jl-main/README.md") do io
    io isa IO
end

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 a pull request may close this issue.

2 participants