Umbrella Project: Chef Foundation
Project State: Active
Issues Response Time Maximum: 14 days
Pull Request Response Time Maximum: 14 days
A Ruby FFI binding to [libarchive].
This library provides Ruby FFI bindings to the well-known libarchive library.
Ensure that you have libarchive installed. On Debian/Ubuntu:
apt install libarchive13
On macOS with Homebrew:
brew install libarchive
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install ffi-libarchive
To extract an archive into the current directory:
flags = Archive::EXTRACT_PERM reader = Archive::Reader.open_filename('/path/to/archive.tgz') reader.each_entry do |entry| reader.extract(entry, flags.to_i) end reader.close
To create a gzipped tar archive:
Archive.write_open_filename('my.tgz', Archive::COMPRESSION_GZIP, Archive::FORMAT_TAR_PAX_RESTRICTED) do |tar| content = File.read 'some_path' size = content.size tar.new_entry do |e| e.pathname = 'some_path' e.size = size e.filetype = Archive::Entry::FILE tar.write_header e tar.write_data content end end
Bug reports and pull requests are welcome on GitHub at https://github.com/chef/ffi-libarchive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Community Guidelines code of conduct.
- License:: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.