Skip to main content

Module pack

Module pack 

Source
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.
PackHeader
Header of a Pack, containing all the header-related info of said Pack.
PackNotes
Pack notes for documentation and collaboration.
PackSettings
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.