Arkiv is a convenience library to download, open, consult and extract archives of various format through a single consistent interface.
sample.zip
(requires the zip feature).sample.tar
(requires thetar
feature).sample.tgz
orsample.tar.gz
(requirestar
andgzip
features).sample.tar.xz
(requirestar
andxz
features).sample.tar.bz2
(requirestar
andbzip
features).sample.tar.zstd
orsample.tar.zst
(requirestar
andzstd
features).
use arkiv::{Result, Archive};
fn main() -> Result<()> {
// open the archive from a local file
let mut archive = arkiv::Archive::open("path/to/archive.tar.xz")?;
// or download it over HTTP(S) - requires the `download` feature.
#[cfg(feature="download")]
let mut archive = {
let url = "https://github.com/meuter/arkiv-rs/raw/main/tests/sample/sample.tar.zstd";
arkiv::Archive::download(url)?
};
// iterate over entries
for entry in archive.entries_iter()? {
let entry = entry?;
println!("{} {}", entry.size(), entry.path().display());
}
// extract the archive (perserves permission on unix targets)
archive.unpack("/tmp/")?;
Ok(())
}