wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::fs::CascStorage Class Reference

Local CASC storage. More...

#include <wowlib/fs/casc/casc_storage.hpp>

Classes

struct  Options
 What to open and how. More...

Public Member Functions

 ~CascStorage ()
 CascStorage (const CascStorage &)=delete
CascStorage & operator= (const CascStorage &)=delete
 CascStorage (CascStorage &&other) noexcept
CascStorage & operator= (CascStorage &&other) noexcept
Result< FileBuffer > readFile (const FileKey &key)
 Read a file into memory.
Result< void > addEncryptionKey (std::uint64_t keyName, std::span< const std::byte, 16 > key)
 Register a TACT encryption key so the storage can decrypt content behind it (encrypted BLTE blocks, and thus the encrypted sections of a .db2).
Result< void > importKeys (std::string_view keyList)
 Register TACT keys from a text list — the community "KeyName KeyHex" per line format (16 hex nibbles name, 32 hex nibbles key).
bool exists (const FileKey &key)
 Whether the file can be opened (probe open + _close).
Result< std::vector< FileDataID > > enumerateFdids ()
 Enumerate every FileDataID the storage holds: entries whose content is locally available and that carry a valid id, deduplicated and sorted.

Static Public Member Functions

static Result< CascStorage > open (Options options)
 Open the local storage.
static constexpr StorageKind kind ()

Detailed Description

Local CASC storage.

FileDataID is the primary address; opening by name is a best-effort fallback that only works on clients whose root manifest still carries name hashes (pre-8.2) — on modern clients resolve paths through a listfile in the composition layer instead.

RAII: open() — the only way to obtain an instance — returns a fully open storage, so a constructed CascStorage is an open one. The destructor (and move-assignment onto an open storage) closes the CascLib handle; the only not-open state C++ can hold is a moved-from storage, which is empty and safe to destroy.

Thread safety: one mutex around the storage handle for the whole open-size-read-_close sequence; CascLib handles are not documented thread-safe. A storage-handle pool is a possible future upgrade (memory-heavy — measure first).

Definition at line 37 of file casc_storage.hpp.

Constructor & Destructor Documentation

◆ ~CascStorage()

wowlib::fs::CascStorage::~CascStorage ( )
inline

Definition at line 59 of file casc_storage.hpp.

◆ CascStorage() [1/2]

wowlib::fs::CascStorage::CascStorage ( const CascStorage & )
delete

◆ CascStorage() [2/2]

wowlib::fs::CascStorage::CascStorage ( CascStorage && other)
inlinenoexcept

Definition at line 64 of file casc_storage.hpp.

References CascStorage().

Member Function Documentation

◆ addEncryptionKey()

Result< void > wowlib::fs::CascStorage::addEncryptionKey ( std::uint64_t keyName,
std::span< const std::byte, 16 > key )

Register a TACT encryption key so the storage can decrypt content behind it (encrypted BLTE blocks, and thus the encrypted sections of a .db2).

Once registered, readFile returns fully-decrypted bytes and the DB2 reader decodes those sections normally instead of reporting them encrypted.

Parameters
keyNamethe 64-bit key lookup (the section header's tactKeyHash).
keythe 16-byte key.
Returns
nothing, or BackendError when CascLib rejects the key.

Definition at line 221 of file casc_storage.cpp.

References wowlib::BackendError, wowlib::makeError(), and wowlib::StorageNotOpen.

◆ enumerateFdids()

Result< std::vector< FileDataID > > wowlib::fs::CascStorage::enumerateFdids ( )

Enumerate every FileDataID the storage holds: entries whose content is locally available and that carry a valid id, deduplicated and sorted.

Modern root manifests are id-keyed, so this is the complete file listing regardless of listfile coverage (name resolution stays the composition layer's job).

Returns
the sorted FileDataIDs, or StorageNotOpen / BackendError.

Definition at line 242 of file casc_storage.cpp.

References wowlib::BackendError, wowlib::makeError(), and wowlib::StorageNotOpen.

◆ exists()

bool wowlib::fs::CascStorage::exists ( const FileKey & key)

Whether the file can be opened (probe open + _close).

Parameters
keythe file identity.
Returns
true if a read would find it.

Definition at line 267 of file casc_storage.cpp.

References wowlib::cascLocaleFlag(), wowlib::FileKey::fdid, and wowlib::FileKey::path.

◆ importKeys()

Result< void > wowlib::fs::CascStorage::importKeys ( std::string_view keyList)

Register TACT keys from a text list — the community "KeyName KeyHex" per line format (16 hex nibbles name, 32 hex nibbles key).

Lines that do not parse are skipped by CascLib.

Parameters
keyListthe newline-separated key list.
Returns
nothing, or BackendError when CascLib rejects the list.

Definition at line 233 of file casc_storage.cpp.

References wowlib::BackendError, wowlib::makeError(), and wowlib::StorageNotOpen.

◆ kind()

constexpr StorageKind wowlib::fs::CascStorage::kind ( )
inlinestaticconstexpr
Returns
the storage technology tag (Casc).

Definition at line 116 of file casc_storage.hpp.

References wowlib::Casc.

◆ open()

Result< CascStorage > wowlib::fs::CascStorage::open ( Options options)
static

Open the local storage.

Fallback ladder for repacks (e.g. WoWCircle) that ship without a root .build.info: (a) plain open of the client root, then Data/; (b) scan Data/config for build configurations, synthesize a .build.info in a temp shim directory (with a Data symlink back to the client) and try each candidate build config until one opens — candidates ordered by Options::build match, then by build number descending.

Parameters
optionswhat to open.
Returns
the open storage, or StorageOpenFailed.

Definition at line 120 of file casc_storage.cpp.

References CascStorage().

Referenced by wowlib::fs::FileSystem::open().

◆ operator=() [1/2]

CascStorage & wowlib::fs::CascStorage::operator= ( CascStorage && other)
inlinenoexcept

Definition at line 69 of file casc_storage.hpp.

References CascStorage().

◆ operator=() [2/2]

CascStorage & wowlib::fs::CascStorage::operator= ( const CascStorage & )
delete

References CascStorage().

◆ readFile()

Result< FileBuffer > wowlib::fs::CascStorage::readFile ( const FileKey & key)

Read a file into memory.

Prefers the FileDataID; falls back to open-by-name for path-only keys (pre-8.2 clients only).

Parameters
keythe file identity.
Returns
the bytes, or FileNotFound / PathNotResolvable / EncryptedContent.

Definition at line 189 of file casc_storage.cpp.

References wowlib::cascLocaleFlag(), wowlib::FileKey::fdid, wowlib::FileNotFound, wowlib::InvalidPath, wowlib::makeError(), wowlib::FileKey::path, wowlib::PathNotResolvable, and wowlib::StorageNotOpen.


The documentation for this class was generated from the following files: