Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexcrichton/tar-rs
Tar file reading/writing for Rust
https://github.com/alexcrichton/tar-rs
Last synced: 2 days ago
JSON representation
Tar file reading/writing for Rust
- Host: GitHub
- URL: https://github.com/alexcrichton/tar-rs
- Owner: alexcrichton
- License: apache-2.0
- Created: 2014-07-17T14:56:29.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-11-10T17:36:57.000Z (about 1 month ago)
- Last Synced: 2024-12-03T05:02:47.978Z (9 days ago)
- Language: Rust
- Homepage: https://docs.rs/tar
- Size: 1.82 MB
- Stars: 627
- Watchers: 13
- Forks: 190
- Open Issues: 107
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-rust-cn - alexcrichton/tar-rs - ci.com/alexcrichton/tar-rs.svg?branch=master">](https://travis-ci.org/alexcrichton/tar-rs) (Libraries / Compression)
- awesome-rust - alexcrichton/tar-rs - ci.com/alexcrichton/tar-rs.svg?branch=master">](https://travis-ci.org/alexcrichton/tar-rs) (Libraries / Compression)
- awesome-rust - alexcrichton/tar-rs - ci.org/alexcrichton/tar-rs.svg?branch=master">](https://travis-ci.org/alexcrichton/tar-rs) (代码 / 压缩)
- awesome-rust - alexcrichton/tar-rs
- awesome-rust-cn - alexcrichton/tar-rs
- awesome-rust-zh - alexcrichton/tar-rs - 在 Rust 中读取/写入 tar 档案[<img src="https://api.travis-ci.com/alexcrichton/tar-rs.svg?branch=master">](https://travis-ci.org/alexcrichton/tar-rs) (库 / 压缩)
- awesome-rust - alexcrichton/tar-rs - tar archive reading/writing (Libraries / Compression)
- awesome-rust - alexcrichton/tar-rs - ci.com/alexcrichton/tar-rs.svg?branch=master">](https://travis-ci.org/alexcrichton/tar-rs) (库 Libraries / 压缩 Compression)
- fucking-awesome-rust - alexcrichton/tar-rs - tar archive reading/writing (Libraries / Compression)
- fucking-awesome-rust - alexcrichton/tar-rs - tar archive reading/writing (Libraries / Compression)
README
# tar-rs
[Documentation](https://docs.rs/tar)
A tar archive reading/writing library for Rust.
```toml
# Cargo.toml
[dependencies]
tar = "0.4"
```## Reading an archive
```rust,no_run
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
```rust,no_run
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
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)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.