Crates.io | tar-wasi |
lib.rs | tar-wasi |
version | 0.4.38 |
source | src |
created_at | 2021-11-19 15:39:46.060037 |
updated_at | 2021-11-20 05:07:50.201116 |
description | A Rust implementation of a TAR file reader and writer. This library does not currently handle compression, but it is abstract over all I/O readers and writers. Additionally, great lengths are taken to ensure that the entire contents are never required to be entirely resident in memory all at once. This fork includes full support for running the library with WebAssembly via the target wasm32-wasi. |
homepage | https://github.com/john-sharratt/tar-rs |
repository | https://github.com/john-sharratt/tar-rs.git |
max_upload_size | |
id | 484498 |
size | 230,204 |
A tar archive reading/writing library for Rust that supports the wasm32-wasi target
# Cargo.toml
[dependencies]
tar-wasi = "0.4"
extern crate tar_wasi;
use std::io::prelude::*;
use std::fs::File;
use tar_wasi::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);
}
}
extern crate tar_wasi;
use std::io::prelude::*;
use std::fs::File;
use tar_wasi::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();
}
This project is licensed under either of
at your option.
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.