Shard Detail

archive v0.4.0

libarchive bindings for Crystal
crystal libarchive zip rar

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


archive:
  github: hkalexling/archive.cr

Readme

archive.cr

CI

archive.cr provides libarchive bindings for Crystal. Only a small subset of the libarchive functions are implemented, and currently only extraction is supported.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      archive:
        github: hkalexling/archive.cr
    
  2. 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