20 breaking releases

new 0.20.0 Nov 17, 2024
0.18.0 Sep 3, 2024
0.15.0 Jul 27, 2024
0.8.0 Mar 6, 2024
0.0.0-alpha.1 Mar 7, 2023

#1322 in Filesystem

Download history 328/week @ 2024-07-27 126/week @ 2024-08-03 360/week @ 2024-08-10 154/week @ 2024-08-17 43/week @ 2024-08-24 278/week @ 2024-08-31 27/week @ 2024-09-07 46/week @ 2024-09-14 144/week @ 2024-09-21 84/week @ 2024-09-28 30/week @ 2024-10-05 271/week @ 2024-10-12 43/week @ 2024-10-19 130/week @ 2024-10-26 66/week @ 2024-11-02 96/week @ 2024-11-09

364 downloads per month
Used in 2 crates

Apache-2.0 OR MIT

265KB
6K SLoC

pna

test Crates.io

A pna archive reading/writing library for Rust.

# Cargo.toml
[dependencies]
pna = "0.20"

Reading an archive

use pna::{Archive, ReadOptions};
use std::fs::File;
use std::io::{self, copy, prelude::*};

fn main() -> io::Result<()> {
    let file = File::open("foo.pna")?;
    let mut archive = Archive::read_header(file)?;
    for entry in archive.entries_skip_solid() {
        let entry = entry?;
        let mut file = File::create(entry.header().path().as_path())?;
        let mut reader = entry.reader(ReadOptions::builder().build())?;
        copy(&mut reader, &mut file)?;
    }
    Ok(())
}

Writing an archive

use pna::{Archive, EntryBuilder, WriteOptions};
use std::fs::File;
use std::io::{self, prelude::*};

fn main() -> io::Result<()> {
    let file = File::create("foo.pna")?;
    let mut archive = Archive::write_header(file)?;
    let mut entry_builder = EntryBuilder::new_file(
        "bar.txt".into(),
        WriteOptions::builder().build(),
    )?;
    entry_builder.write(b"content")?;
    let entry = entry_builder.build()?;
    archive.add_entry(entry)?;
    archive.finalize()?;
    Ok(())
}

CLI

Command line user interface are available, and you can install via cargo or build from source.

Via Cargo

cargo install portable-network-archive

From Source (via Cargo)

cargo install --git https://github.com/ChanTsune/Portable-Network-Archive.git portable-network-archive

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.

Dependencies

~12MB
~208K SLoC