Tar archive library for Rust
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Valentin Isipchuk 2349b49482
Some checks failed
CI / Test (beta) (push) Has been cancelled
CI / Test (macos) (push) Has been cancelled
CI / Test (nightly) (push) Has been cancelled
CI / Test (stable) (push) Has been cancelled
CI / Test (windows) (push) Has been cancelled
CI / Wasm (push) Has been cancelled
CI / Rustfmt (push) Has been cancelled
CI / Semver Checks (push) Has been cancelled
CI / Reverse deps (push) Has been cancelled
CI / Publish Documentation (push) Has been cancelled
CI / required-checks (push) Has been cancelled
Add support of absolute paths
Fix failed on windows test

Add test to verify unpacking of archive with absolute path

Remove allow_absolute parameter from public Builder methods

Fix semver; Add methods to header to set absolute path
2026-04-04 07:35:45 -04:00
.cargo ci: Add xtask infra + reverse dependency testing (#435) 2026-03-03 16:57:45 -05:00
.github ci: Fix and re-enable reverse dependency testing (#444) 2026-03-20 00:04:59 +01:00
examples refactor: implement recommendations from clippy (#401) 2025-06-05 20:07:32 +00:00
fuzz OSS-Fuzz: Use derive via Arbitrary feature flag (#416) 2025-10-07 16:03:54 -04:00
src Add support of absolute paths 2026-04-04 07:35:45 -04:00
tests Add support of absolute paths 2026-04-04 07:35:45 -04:00
xtask ci: Fix and re-enable reverse dependency testing (#444) 2026-03-20 00:04:59 +01:00
.gitignore ci: Add xtask infra + reverse dependency testing (#435) 2026-03-03 16:57:45 -05:00
Cargo.toml Update astral-tokio-tar requirement from 0.5 to 0.6 2026-03-31 19:17:14 -04:00
LICENSE-APACHE Add a dual Apache/MIT license 2014-09-03 11:21:09 -07:00
LICENSE-MIT Update LICENSE-MIT (#396) 2025-02-25 15:25:26 -06:00
README.md Update some links 2026-03-31 19:17:55 -04:00

tar-rs

Documentation

A tar archive reading/writing library for Rust.

# Cargo.toml
[dependencies]
tar = "0.4"

Reading an archive

extern crate tar;

use std::io::prelude::*;
use std::fs::File;
use tar::Archive;

fn main() {
    let file = File::open("foo.tar").unwrap();
    let mut a = Archive::new(file);

    for file in a.entries().unwrap() {
        // Make sure there wasn't an I/O error
        let mut file = file.unwrap();

        // Inspect metadata about the file
        println!("{:?}", file.header().path().unwrap());
        println!("{}", file.header().size().unwrap());

        // files implement the Read trait
        let mut s = String::new();
        file.read_to_string(&mut s).unwrap();
        println!("{}", s);
    }
}

Writing an archive

extern crate tar;

use std::io::prelude::*;
use std::fs::File;
use tar::Builder;

fn main() {
    let file = File::create("foo.tar").unwrap();
    let mut a = Builder::new(file);

    a.append_path("file1.txt").unwrap();
    a.append_file("file2.txt", &mut File::open("file3.txt").unwrap()).unwrap();
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.