Expand description
A library for more useful reading and writing PNA archives
Provides filesystem-related utilities in addition to the utilities
necessary to manage PNA archives abstracted over a reader or writer hosted by libpna.
§pna
A pna archive reading/writing library for Rust.
# Cargo.toml
[dependencies]
pna = "0.30"§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
A command-line interface (CLI) is available. You can install it 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
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.
Modules§
Structs§
- Archive
- An object providing access to a PNA file. An instance of an Archive can be read and/or written.
- Chunk
Type - A 4-byte chunk type code.
- Compression
Level - Compression level of each algorithm.
- Duration
- A span of time with nanosecond precision.
- Entry
Builder - A builder for creating a
NormalEntry. - Entry
Data Reader - Reader for Entry data.
- Entry
Header - Represents the entry information header that expressed in the FHED chunk.
- Entry
Name - A UTF-8 encoded entry name.
- Entry
Name Error - Error of invalid EntryName.
- Entry
Part - A structure representing the split Entry for archive splitting.
- Entry
Reference - A UTF-8 encoded entry reference.
- Entry
Reference Error - Error of invalid EntryReference.
- Extended
Attribute - Represents a single extended attribute of a file entry.
- Hash
Algorithm - Password hash algorithm.
- Metadata
- Metadata information about an entry.
- Normal
Entry - A normal entry in a PNA archive.
- Permission
- Permission struct represents an owner, group, and permissions for an entry.
- RawChunk
- A raw chunk in a PNA archive.
- Read
Options - Options for reading an entry.
- Read
Options Builder - Builder for
ReadOptions. - Solid
Archive - An object that provides write access to solid mode PNA files.
- Solid
Entry - A solid mode entry in a PNA archive.
- Solid
Entry Builder - A builder for creating a
SolidEntry. - Solid
Header - Represents the entry information header that expressed in the SHED chunk.
- Unknown
Value Error - Unknown value error.
- Write
Options - Options for writing entries to a PNA archive.
- Write
Options Builder - Builder for
WriteOptions.
Enums§
- Chunk
Type Error - ChunkType validation error.
- Cipher
Algorithm - Cipher algorithm.
- Cipher
Mode - Cipher mode of encryption algorithm.
- Compression
- Compression method.
- Data
Kind - Type of filesystem object represented by an entry.
- Encryption
- Encryption algorithm.
- Read
Entry - A NormalEntry or SolidEntry read from an archive.
Constants§
- MIN_
CHUNK_ BYTES_ SIZE - The minimum size of a PNA chunk in bytes.
- PNA_
HEADER - The magic number of Portable-Network-Archive
Traits§
- Chunk
- A trait representing a chunk in a PNA archive.
- Entry
- A trait representing an entry in a PNA archive.
Functions§
- read_
as_ chunks - Reads an archive as chunks from the given reader.
- read_
chunks_ from_ slice - Reads an archive as chunks from the given bytes.