rustpak
Rust library and CLI tool for reading and writing GoldSrc .pak archive files.
About
The .pak format is a simple archive format used by Quake, Half-Life, and other GoldSrc engine games to package game assets. This library provides functionality to parse, create, and modify .pak archives.
Features
- Parse existing
.pakfiles - Create new
.pakarchives - Add, remove, and extract files
- CLI tool for common operations
- Full binary format validation
- Supports files with directory structures
Installation
CLI Tool
Library
Add to your Cargo.toml:
[]
= "0.1"
Usage
CLI
List files in a .pak archive:
Extract a file:
Extract with directory structure:
Append a file to an archive:
Library
use Pak;
use PakFileEntry;
// Load an existing archive
let mut pak = from_file?;
// List all files
for file in &pak.files
// Add a new file
let data = b"Hello, world!".to_vec;
let entry = new;
pak.add_file?;
// Save modifications
pak.save?;
Extract a file:
use Pak;
let pak = from_file?;
for file in &pak.files
Pak File Format
A .pak file consists of three parts:
-
Header (12 bytes)
- Magic: "PACK" (4 bytes)
- Directory offset: Offset to directory (4 bytes)
- Directory size: Size of directory (4 bytes)
-
Directory (64 bytes per file)
- File name: Null-terminated string, 56 bytes
- File offset: Offset to file data (4 bytes)
- File size: Size of file data (4 bytes)
-
File Data
- Raw file contents at offsets specified in directory
Documentation
Full API documentation is available at docs.rs
License
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Based on the original Quake
.pakformat specification - Inspired by various GoldSrc modding tools