Expand description
PackFile (.pack) container format for Total War games.
This module handles reading and writing PackFiles, the primary container format used by Total War games to store game assets. PackFiles bundle multiple files into a single archive with optional compression and encryption support.
§Overview
PackFiles have evolved through multiple versions since Empire: Total War, with each version adding features like timestamps, compression, and encryption. This module supports all known PackFile versions (PFH0 through PFH6).
§Pack Types
Packs have different types that determine load order and behavior:
- Boot: Core game files loaded first
- Release: Official game content
- Patch: Official patches
- Mod: User-created modifications
- Movie: Video content packs
§Features
- Lazy Loading: Files can be loaded on-demand to reduce memory usage
- Compression: PFH5+ supports LZ4, Zlib, and LZMA compression (game-dependent)
- Encryption: Packs support index and data encryption
- Timestamps: Track when files were last modified
- Dependencies: Packs can declare dependencies on other packs
- Metadata: Store notes and settings within the pack itself
§Example
use rpfm_lib::files::pack::Pack;
use rpfm_lib::files::{Container, Decodeable, DecodeableExtraData};
use std::fs::File;
use std::io::BufReader;
// Open and read a pack file
let file = File::open("my_mod.pack").unwrap();
let mut reader = BufReader::new(file);
let mut extra_data = DecodeableExtraData::default();
extra_data.set_lazy_load(true);
let pack = Pack::decode(&mut reader, &Some(extra_data)).unwrap();
println!("Pack contains {} files", pack.files().len());Structs§
- PFHFlags
- This represents the bitmasks a Pack can have applied to his type.
- Pack
- Packs are a container-type file, used for “packing” all game assets into single files, to speed up disk reads.
- Pack
Header - Header of a Pack, containing all the header-related info of said Pack.
- Pack
Notes - Pack notes for documentation and collaboration.
- Pack
Settings - Pack-specific settings stored within the pack itself.
Constants§
- EXTENSION
- File extension used by PackFiles.
- RESERVED_
NAME_ DEPENDENCIES_ MANAGER - Reserved filename for legacy dependency manager data.
- RESERVED_
NAME_ DEPENDENCIES_ MANAGER_ V2 - Reserved filename for dependency manager data (current version).
- RESERVED_
NAME_ EXTRA_ PACKFILE - Reserved filename for extra packfile references.
- RESERVED_
NAME_ NOTES - Reserved filename for pack notes data.
- RESERVED_
NAME_ NOTES_ EXTRACTED - Reserved filename for extracted pack notes (Markdown format).
- RESERVED_
NAME_ SETTINGS - Reserved filename for pack settings data.
- RESERVED_
NAME_ SETTINGS_ EXTRACTED - Reserved filename for extracted pack settings (JSON format).
- RESERVED_
RFILE_ NAMES - List of reserved filenames used by RPFM for internal purposes.
- SETTING_
KEY_ CF - Settings key for the compression format used by this pack.