• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H03-May-2022-7065

examples/H03-May-2022-10775

src/H03-May-2022-4,0032,681

tests/H03-May-2022-1,8751,526

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D29-Nov-197320 32

Cargo.lockH A D01-Jan-19704.2 KiB170150

Cargo.tomlH A D01-Jan-19701.4 KiB3935

Cargo.toml.orig-cargoH A D29-Nov-1973893 3327

LICENSE-APACHEH A D29-Nov-197310.6 KiB202169

LICENSE-MITH A D29-Nov-19731 KiB2622

README.mdH A D29-Nov-19731.6 KiB7754

README.md

1# tar-rs
2
3[Documentation](https://docs.rs/tar)
4
5A tar archive reading/writing library for Rust.
6
7```toml
8# Cargo.toml
9[dependencies]
10tar = "0.4"
11```
12
13## Reading an archive
14
15```rust,no_run
16extern crate tar;
17
18use std::io::prelude::*;
19use std::fs::File;
20use tar::Archive;
21
22fn main() {
23    let file = File::open("foo.tar").unwrap();
24    let mut a = Archive::new(file);
25
26    for file in a.entries().unwrap() {
27        // Make sure there wasn't an I/O error
28        let mut file = file.unwrap();
29
30        // Inspect metadata about the file
31        println!("{:?}", file.header().path().unwrap());
32        println!("{}", file.header().size().unwrap());
33
34        // files implement the Read trait
35        let mut s = String::new();
36        file.read_to_string(&mut s).unwrap();
37        println!("{}", s);
38    }
39}
40
41```
42
43## Writing an archive
44
45```rust,no_run
46extern crate tar;
47
48use std::io::prelude::*;
49use std::fs::File;
50use tar::Builder;
51
52fn main() {
53    let file = File::create("foo.tar").unwrap();
54    let mut a = Builder::new(file);
55
56    a.append_path("file1.txt").unwrap();
57    a.append_file("file2.txt", &mut File::open("file3.txt").unwrap()).unwrap();
58}
59```
60
61# License
62
63This project is licensed under either of
64
65 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
66   http://www.apache.org/licenses/LICENSE-2.0)
67 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
68   http://opensource.org/licenses/MIT)
69
70at your option.
71
72### Contribution
73
74Unless you explicitly state otherwise, any contribution intentionally submitted
75for inclusion in this project by you, as defined in the Apache-2.0 license,
76shall be dual licensed as above, without any additional terms or conditions.
77