| Crates.io | bg3rustpaklib |
| lib.rs | bg3rustpaklib |
| version | 0.1.1 |
| created_at | 2026-01-13 19:50:14.66492+00 |
| updated_at | 2026-01-13 19:51:55.439685+00 |
| description | A Rust library for reading and extracting Baldur's Gate 3 PAK files |
| homepage | |
| repository | https://github.com/defakof/bg3rustpaklib |
| max_upload_size | |
| id | 2041060 |
| size | 113,467 |
A Rust library for reading, extracting, and creating Baldur's Gate 3 PAK files.
This library provides functionality for working with Larian Studios' PAK (LSPK) archive format used in Baldur's Gate 3. It is similar to lslib but written in Rust.
async featureAdd to your Cargo.toml:
[dependencies]
bg3rustpaklib = "0.1"
use bg3rustpaklib::{Package, PackageSearch};
fn main() -> bg3rustpaklib::Result<()> {
// Open a PAK file
let package = Package::open("Game.pak")?;
// Get package metadata
let metadata = package.metadata();
println!("Package version: {}", metadata.version);
println!("File count: {}", metadata.file_count);
// List all files
for file in package.files() {
println!("{} ({} bytes)", file.name(), file.size());
}
// Find files by pattern
let lsf_files = package.find("**/*.lsf");
println!("Found {} .lsf files", lsf_files.len());
// Extract a specific file
if let Some(file) = package.get("Public/Game/GUI/Assets/Tooltips/tooltip.lsf") {
let contents = package.read_file(file)?;
println!("File size: {} bytes", contents.len());
}
// Extract all files to a directory
package.extract_all("output/")?;
Ok(())
}
Enable the async feature for async APIs:
[dependencies]
bg3rustpaklib = { version = "0.1", features = ["async"] }
use bg3rustpaklib::AsyncPackage;
#[tokio::main]
async fn main() -> bg3rustpaklib::Result<()> {
let package = AsyncPackage::open("Game.pak").await?;
let metadata = package.metadata().await;
println!("File count: {}", metadata.file_count);
Ok(())
}
Several example tools are included:
Dumps hex view of the first and last 64 bytes of a PAK file:
cargo run --example dump_header path/to/file.pak
Shows detailed package information including file list:
cargo run --example detailed_dump path/to/file.pak
Compares multiple PAK files and shows their metadata:
cargo run --example compare_paks path/to/pak1.pak path/to/pak2.pak
Demonstrates extracting and repacking a PAK file:
cargo run --example repack_test input.pak output.pak
# Build the library
cargo build
# Build with async support
cargo build --features async
# Run tests
cargo test
# Build examples
cargo build --examples
See docs.rs for full API documentation.
MIT License - see LICENSE file for details.
Inspired by lslib by Norbyte.