archive.cr v0.5.0
archive.cr
archive.cr
provides libarchive bindings for Crystal. Only a small subset of the libarchive functions are implemented, and currently only extraction is supported.
Installation
-
Add the dependency to your
shard.yml
:dependencies: archive: github: hkalexling/archive.cr
-
Run
shards install
Usage
require "archive"
# Extract all entries
Archive::File.open "file.zip" do |f|
f.entries.map do |e|
# Skip non-file entries
next unless e.info.file?
filename = e.filename
size = e.size
file = File.new filename, "wb"
file.write e.read
end
end
# Extract a specific entry
Archive::File.open "file.zip" do |f|
file = File.new "img.jpg", "wb"
file.write f.read_entry "img.jpg"
end
Repository
archive.cr
Owner
Statistic
- 2
- 1
- 0
- 5
- 0
- over 2 years ago
- May 24, 2020
License
MIT License
Links
Synced at
Fri, 03 May 2024 05:32:18 GMT
Languages