Crate pf8

Crate pf8 

Source
Expand description

§PF6/PF8 Archive Library

A Rust library for encoding and decoding PF6 and PF8 archive files.

  • PF6: Unencrypted format for simple file archiving
  • PF8: Encrypted format with XOR encryption using SHA1-based keys

§Quick Start

§Reading PF6/PF8 Archives

use pf8::{Pf8Archive, Result, create_from_dir};

// Open an existing PF6/PF8 archive
let mut archive = Pf8Archive::open(&archive_path)?;

// List all files in the archive
for entry in archive.entries() {
    println!("{}: {} bytes", entry.path().display(), entry.size());
}

// Extract all files to a directory
let output_dir = temp_dir.path().join("output");
archive.extract_all(&output_dir)?;

// Extract a specific file
if let Some(_entry) = archive.get_entry("test.txt") {
    let data = archive.read_file("test.txt")?;
    let output_file = temp_dir.path().join("extracted_file.txt");
    std::fs::write(output_file, data)?;
}

§Creating PF8 Archives

use pf8::{Pf8Builder, Result};

// Create a new archive builder
let mut builder = Pf8Builder::new();

// Add files and directories
builder.add_dir(&input_dir)?;
builder.add_file(&single_file)?;
// builder.add_file_as("config.toml", "settings/config.toml")?;

// Write the archive to a file
builder.write_to_file(&output_path)?;

§Features

  • Streaming Support: Read and write archives without loading everything into memory
  • Dual Format Support:
    • PF6: Simple unencrypted format
    • PF8: Encrypted format with XOR encryption and SHA1-based keys
  • Flexible API: Both high-level convenience methods and low-level control
  • Path Handling: Automatic conversion between system paths and internal format
  • Error Handling: Comprehensive error types with detailed messages

Re-exports§

pub use archive::Pf8Archive;
pub use builder::Pf8Builder;
pub use callbacks::ArchiveError;
pub use callbacks::ArchiveEvent;
pub use callbacks::ArchiveHandler;
pub use callbacks::ControlAction;
pub use callbacks::OperationType;
pub use callbacks::ProgressInfo;
pub use entry::Pf8Entry;
pub use error::Error;
pub use error::Result;
pub use reader::Pf8Reader;
pub use writer::Pf8Writer;
pub use archive::create_from_dir;
pub use archive::create_from_dir_with_progress;
pub use archive::extract;
pub use display::list_archive;

Modules§

archive
High-level archive operations for PF6/PF8 files.
builder
Builder for creating PF8 archives.
callbacks
Callback interfaces for progress reporting and cancellation support.
display
Display functionality for PF8 archives (requires ‘display’ feature).
entry
File entry representation and operations.
error
Error types for the PF8 library.
reader
High-level reader for PF6/PF8 archives.
writer
Writer for creating PF8 archives.

Enums§

ArchiveFormat
Archive format type