tar-rs

Tar file reading/writing for Rust

  • 所有者: alexcrichton/tar-rs
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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.

主要指标

概览
名称与所有者alexcrichton/tar-rs
主编程语言Rust
编程语言Rust (语言数: 2)
平台
许可证Apache License 2.0
所有者活动
创建于2014-07-17 14:56:29
推送于2025-07-12 15:39:39
最后一次提交
发布数71
最新版本名称0.4.44 (发布于 )
第一版名称0.1.0 (发布于 )
用户参与
星数678
关注者数14
派生数216
提交数529
已启用问题?
问题数199
打开的问题数80
拉请求数142
打开的拉请求数35
关闭的拉请求数33
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?