bg3rustpaklib
A Rust library for reading, extracting, and creating Baldur's Gate 3 PAK files.
Overview
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.
Features
- Read PAK files - Supports versions 15, 16, and 18 (BG3 format)
- List and search files - Find files by pattern or search within packages
- Extract files - Extract individual files or entire packages to disk
- Create PAK files - Build new packages from directories
- Compression support - LZ4 and Zstd decompression
- Solid archives - Support for solid archive handling
- Async API - Optional async support via
asyncfeature
Usage
Add to your Cargo.toml:
[]
= "0.1"
Basic Example
use ;
Async Support
Enable the async feature for async APIs:
[]
= { = "0.1", = ["async"] }
use AsyncPackage;
async
Command-line Tools
Several example tools are included:
dump_header
Dumps hex view of the first and last 64 bytes of a PAK file:
detailed_dump
Shows detailed package information including file list:
compare_paks
Compares multiple PAK files and shows their metadata:
repack_test
Demonstrates extracting and repacking a PAK file:
Building
# Build the library
# Build with async support
# Run tests
# Build examples
API Reference
See docs.rs for full API documentation.
License
MIT License - see LICENSE file for details.
Credits
Inspired by lslib by Norbyte.