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

Add an unzip function #74

Open
zerefwayne opened this issue Nov 4, 2020 · 3 comments
Open

Add an unzip function #74

zerefwayne opened this issue Nov 4, 2020 · 3 comments

Comments

@zerefwayne
Copy link

Currently if I need to unzip a folder, I'll have to write:

r = ZipFile.Reader("/tmp/example.zip");
for f in r.files
    println("Filename: \$(f.name)")
    write(stdout, read(f, String));
end

Instead, there can be a ZipFile.unzip("/tmp/example.zip") which will place all the data in /tmp/example directory and return me the path of the directory.

@fhs
Copy link
Owner

fhs commented Nov 4, 2020

The code above just writes the content of each file to stdout. I'm guessing you want a function that extracts all files in a directory. In that case, I'd rather have the user specify the destination directory rather than return it.

@chelate
Copy link

chelate commented Dec 8, 2023

I really don't know how to write a pr but there is decent code here, experimental, but it works for most use cases. Bump for adding this because InfoZIP is not being maintained and has problems with its .toml file, and can't be installed. I'd be very sad if I can't find a package to unzip a file in julia!

@nhz2
Copy link

nhz2 commented Dec 15, 2023

Unfortunately, this is quite complicated to do in a cross-platform manner that safely handles all potential errors or malicious zip archives. The code you link to has a few big issues but will sometimes work.

For now, I would recommend using p7zip_jll

Here is an example I have:
https://github.com/JuliaIO/ZipArchives.jl/blob/d96b54d03636f0976e3f276896572b398a623d79/test/external_unzippers.jl#L16C1-L26C4

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

No branches or pull requests

4 participants