Crates.io | libpna |
lib.rs | libpna |
version | 0.19.0 |
source | src |
created_at | 2023-03-06 06:25:46.708081 |
updated_at | 2024-10-15 13:17:11.457517 |
description | PNA(Portable-Network-Archive) decoding and encoding library |
homepage | |
repository | https://github.com/ChanTsune/Portable-Network-Archive.git |
max_upload_size | |
id | 802195 |
size | 300,140 |
A pna archive reading/writing library for Rust.
# Cargo.toml
[dependencies]
libpna = "0.19"
use libpna::{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(())
}
use libpna::{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(())
}
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.