PF8 - Rust Library for PF6/PF8 Archive Files
A comprehensive Rust library for encoding and decoding PF6 and PF8 archive files. This library provides both high-level convenience APIs and low-level control for working with these archive formats.
PF6 and PF8 are proprietary archive formats for the Artemis galgame engine.
Features
- Multiple Format Support:
- PF6: Read-only support, no encryption
- PF8: Full read/write support with XOR encryption
- Streaming Support: Read and write archives without loading everything into memory
- Built-in Encryption: XOR encryption with SHA1-based keys (PF8 only)
- Flexible API: Both high-level convenience methods and low-level control
- Path Handling: Automatic conversion between system paths and archive internal format
- Comprehensive Error Handling: Detailed error types with helpful messages
- Optional Display Features: Pretty-printed archive listings (requires
displayfeature)
Quick Start
Add this to your Cargo.toml:
[]
= "0.1"
# Without display features (pretty-printed tables)
= { = "0.1", = false }
Convenience Functions
For simple operations, use the convenience functions:
use ;
Reading PF8 Archives
use ;
Creating PF8 Archives
use ;
Display Features
With the display feature enabled, you can pretty-print archive contents:
use list_archive;
This will output a formatted table like:
archive.pfs
| File | Size |
|-------------------|-----------|
| config/game.ini | 1.2 KB |
| image/image1.png | 45.6 MB |
| scripts/main.ast | 3.4 KB |
Total: 3 files, Total size: 45.6 MB
Advanced Usage
Low-level Reader API
use ;
Custom Encryption Patterns
use ;
Streaming Operations
For large archives, you can use streaming operations to avoid loading everything into memory:
use ;
Error Handling
The library provides comprehensive error types:
use ;
PF8 Format Details
The PF8 format is a custom archive format with the following features:
- Magic Number: Files start with "pf8" (3 bytes)
- Index Structure: Contains file names, offsets, and sizes
- XOR Encryption: File contents are encrypted using XOR with SHA1-derived keys
- Path Format: Uses backslash separators internally
- Little-Endian: All multi-byte integers are stored in little-endian format
Performance Considerations
- Streaming operations for files read/write
- The
displayfeature adds dependencies - disable if not needed - Encryption/decryption is performed in-memory
License
This project is licensed under the MIT license - see the LICENSE file for details.