An alternate ZIP reader and writer for Crystal.
- Drop-in replacement for
Compress::Zip
- Allows you to compress files bigger than 4GB
- Tested on Linux, macOS and Windows
Extracted from crystal-lang/crystal#11396. Based on crystal-lang/crystal#7236.
Inspired by https://github.com/WeTransfer/cr_zip_tricks
-
Add the dependency to your
shard.yml
:dependencies: zip64: github: crystal-garage/crystal-zip64
-
Run
shards install
require "zip64"
Zip64::Reader.open("./file.zip") do |zip|
zip.each_entry do |entry|
p entry.filename
p entry.file?
p entry.dir?
p entry.io.gets_to_end
end
end
File.open("./file.zip", "w") do |file|
Zip64::Writer.open(file) do |zip|
# Add a file with a String content
zip.add "foo.txt", "contents of foo"
# Add a file and write data to it through an IO
zip.add("bar.txt") do |io|
io << "contents of bar"
end
# Add a file by referencing a file in the filesystem
# (the file is automatically closed after this call)
zip.add("baz.txt", File.open("./some_file.txt"))
# Add a directory
zip.add_dir("dir")
end
end
- Fork it (https://github.com/crystal-garage/crystal-zip64/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Julik Tarkhanov - creator and maintainer
- Anton Maminov - maintainer