libpna

test Crates.io

A pna archive reading/writing library for Rust.

```toml

Cargo.toml

[dependencies] libpna = "0.2" ```

Reading an archive

```rust use libpna::Archive; use std::fs::File; use std::io::{self, copy, prelude::*};

fn main() -> io::Result<()> { use libpna::ReadOption; let file = File::open("foo.pna")?; let mut archive = Archive::readheader(file)?; for entry in archive.entries() { let entry = entry?; let mut file = File::create(entry.header().path().aspath())?; let mut reader = entry.into_reader(ReadOption::builder().build())?; copy(&mut reader, &mut file)?; } Ok(()) } ```

Writing an archive

```rust use libpna::{Archive, EntryBuilder, WriteOption}; use std::fs::File; use std::io::{self, prelude::*};

fn main() -> io::Result<()> { let file = File::create("foo.pna")?; let mut archive = Archive::writeheader(file)?; let mut entrybuilder = EntryBuilder::newfile( "bar.txt".tryinto().unwrap(), WriteOption::builder().build(), )?; entrybuilder.write(b"content")?; let entry = entrybuilder.build()?; archive.add_entry(entry)?; archive.finalize()?; Ok(()) } ```

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.