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.34"§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
- Provides read and write access to a PNA file.
- Chunk
Type - A 4-byte chunk type code.
- Compression
Level - Compression level of each algorithm.
- Duration
- A span of time with nanosecond precision.
- Encoded
Data Reader - Reader for encoded entry data.
- Entry
Builder - A builder for creating a
NormalEntry. - Entry
Data Reader - Reader for Entry data.
- Entry
Header - Represents the entry information header expressed in the
FHEDchunk. - Entry
Name - A UTF-8 encoded entry name.
- Entry
Name Error - An error returned when an
EntryNamecannot be constructed from invalid input. - Entry
Part - A structure representing the split
Entryfor archive splitting. - Entry
Reference - A UTF-8 encoded entry reference.
- Entry
Reference Error - An error returned when an
EntryReferencecannot be constructed from invalid input. - Extended
Attribute - Represents a single extended attribute of a file entry.
- Hash
Algorithm - Password hash algorithm.
- Length
Exceeded - Error returned when a value exceeds the byte-length bound of a bounded owned string or byte slice.
- Metadata
- Metadata information about an entry.
- Normal
Entry - A normal entry in a PNA archive.
- Owner
Gid - Owner group id (
fGId). - Owner
Group Name - Owner group name (
fGNm). - Owner
Group Sid - Owner group SID (
fGSi). - Owner
Uid - Owner user id (
fUId). - Owner
User Name - Owner user name (
fONm). - Owner
User Sid - Owner user SID (
fOSi). - Permission
Deprecated - Owner, group, and permission bits for an archive entry.
- Permission
Mode - POSIX permission mode (
fMOd). Reserved bits outside0o7777(the rwx + setuid/setgid/sticky bits) are masked to 0 on construction. - RawChunk
- A raw chunk in a PNA archive.
- Read
Options - Options for reading an entry.
- Read
Options Builder - Builder for
ReadOptions. - Solid
Archive - 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 expressed in the
SHEDchunk. - Unknown
Value Error - Unknown value error.
- Write
Options - Options for writing entries to a PNA archive.
- Write
Options Builder - Builder for
WriteOptions. - Xattr
Name - Extended-attribute name identifier.
- Xattr
Value - Extended-attribute value (arbitrary bytes).
Enums§
- Chunk
Type Error ChunkTypevalidation 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.
- Link
Target Type - Link target type for link entries.
- Read
Entry - A
NormalEntryorSolidEntryread 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.