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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?