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

#include <wowlib/fs/filesystem.hpp>

Public Member Functions

Result< FileBuffer > readFile (const FileKey &key)
Result< FileBuffer > readFile (std::string_view path)
 Read a file by client-internal path.
Result< FileBuffer > readFile (FileDataID fdid)
 Read a file by FileDataID.
bool exists (const FileKey &key)
 Whether a file is reachable in the overlay or the storage.
bool exists (std::string_view path)
 Whether a path is reachable.
bool exists (FileDataID fdid)
 Whether a FileDataID is reachable.
Result< std::vector< std::string > > enumeratePaths ()
FileKey resolve (const FileKey &key) const
Result< FileDataID > addFile (std::string_view path, std::span< const std::byte > content)
Result< void > importKeys (std::string_view keyList)
 Register TACT encryption keys (CASC clients only) so the storage can decrypt content behind them — including the encrypted sections of a .db2, which then decode normally instead of being reported encrypted.
Result< void > addEncryptionKey (std::uint64_t keyName, std::span< const std::byte, 16 > key)
 Register one TACT encryption key (CASC clients only).
StorageKind kind () const
 Which storage technology backs this filesystem: Mpq or Casc.
ClientVersion version () const
 The client version this filesystem was opened for — the anchor of version-agnostic code (expansion_of, for_version, Table.open).
MpqFileSystem * mpq ()
 The MPQ composition, for C++ callers that want the static types.
CascFileSystem * casc ()
 The CASC composition, for C++ callers that want the static types.
 FileSystem (MpqFileSystem impl, ClientVersion version)
 C++-only; target languages construct through open().
 FileSystem (CascFileSystem impl, ClientVersion version)
 C++-only; target languages construct through open().

Static Public Member Functions

static Result< FileSystem > open (FileSystemSettings settings)

Protected Member Functions

void close ()
bool isOpen () const
 Whether the filesystem still holds its storage (false after close()).

Detailed Description

Definition at line 64 of file filesystem.hpp.

Constructor & Destructor Documentation

◆ FileSystem() [1/2]

wowlib::fs::FileSystem::FileSystem ( MpqFileSystem impl,
ClientVersion version )
inlineexplicit

C++-only; target languages construct through open().

Parameters
implthe ready MPQ composition.
versionthe client version the composition was opened for.

Definition at line 166 of file filesystem.hpp.

References version().

Referenced by open().

◆ FileSystem() [2/2]

wowlib::fs::FileSystem::FileSystem ( CascFileSystem impl,
ClientVersion version )
inlineexplicit

C++-only; target languages construct through open().

Parameters
implthe ready CASC composition.
versionthe client version the composition was opened for.

Definition at line 172 of file filesystem.hpp.

References version().

Member Function Documentation

◆ addEncryptionKey()

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

Register one TACT encryption key (CASC clients only).

C++-only; scripting callers use importKeys with the text format.

Parameters
keyNamethe 64-bit key lookup (a section's tactKeyHash).
keythe 16-byte key.
Returns
nothing, or NotSupported on an MPQ client, or a backend error.

Definition at line 144 of file filesystem.hpp.

References casc(), wowlib::makeError(), and wowlib::NotSupported.

◆ addFile()

Result< FileDataID > wowlib::fs::FileSystem::addFile ( std::string_view path,
std::span< const std::byte > content )
Returns
the file's FileDataID (0 on MPQ-era clients)
Parameters
paththe client-internal path of the file
contentthe file contents

Definition at line 140 of file filesystem.cpp.

◆ casc()

CascFileSystem * wowlib::fs::FileSystem::casc ( )
inline

The CASC composition, for C++ callers that want the static types.

Returns
the composition, or nullptr if this filesystem is MPQ-backed.

Definition at line 161 of file filesystem.hpp.

Referenced by addEncryptionKey(), and importKeys().

◆ close()

void wowlib::fs::FileSystem::close ( )
inlineprotected

Definition at line 179 of file filesystem.hpp.

◆ enumeratePaths()

Result< std::vector< std::string > > wowlib::fs::FileSystem::enumeratePaths ( )
Returns
the sorted canonical paths

Definition at line 110 of file filesystem.cpp.

◆ exists() [1/3]

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

Whether a file is reachable in the overlay or the storage.

Returns
true if a read would find it
Parameters
keythe file identity (path, id, or both)

Definition at line 103 of file filesystem.cpp.

Referenced by exists(), and exists().

◆ exists() [2/3]

bool wowlib::fs::FileSystem::exists ( FileDataID fdid)
inline

Whether a FileDataID is reachable.

Returns
true if a read would find it
Parameters
fdidthe numeric file identifier

Definition at line 109 of file filesystem.hpp.

References exists().

◆ exists() [3/3]

bool wowlib::fs::FileSystem::exists ( std::string_view path)
inline

Whether a path is reachable.

Returns
true if a read would find it
Parameters
paththe client-internal file path

Definition at line 101 of file filesystem.hpp.

References exists().

◆ importKeys()

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

Register TACT encryption keys (CASC clients only) so the storage can decrypt content behind them — including the encrypted sections of a .db2, which then decode normally instead of being reported encrypted.

Takes the community "KeyName KeyHex" per-line text format.

Parameters
keyListthe newline-separated key list.
Returns
nothing, or NotSupported on an MPQ client, or a backend error. Register TACT encryption keys (CASC only) from the community 'KeyName KeyHex' per-line text, so encrypted .db2 sections decrypt and decode.
nothing; raises on an MPQ client or a malformed list
Parameters
keyListnewline-separated 'KeyName KeyHex' lines

Definition at line 134 of file filesystem.hpp.

References casc(), wowlib::makeError(), and wowlib::NotSupported.

◆ isOpen()

bool wowlib::fs::FileSystem::isOpen ( ) const
inlineprotected

Whether the filesystem still holds its storage (false after close()).

Definition at line 182 of file filesystem.hpp.

◆ kind()

StorageKind wowlib::fs::FileSystem::kind ( ) const
inline

Which storage technology backs this filesystem: Mpq or Casc.

A static fact of the opened client; remains valid after close().

Definition at line 150 of file filesystem.hpp.

◆ mpq()

MpqFileSystem * wowlib::fs::FileSystem::mpq ( )
inline

The MPQ composition, for C++ callers that want the static types.

Returns
the composition, or nullptr if this filesystem is CASC-backed.

Definition at line 157 of file filesystem.hpp.

◆ open()

◆ readFile() [1/3]

Result< FileBuffer > wowlib::fs::FileSystem::readFile ( const FileKey & key)
Returns
the file bytes
Parameters
keythe file identity (path, id, or both)

Definition at line 96 of file filesystem.cpp.

Referenced by readFile(), and readFile().

◆ readFile() [2/3]

Result< FileBuffer > wowlib::fs::FileSystem::readFile ( FileDataID fdid)
inline

Read a file by FileDataID.

Returns
the file bytes
Parameters
fdidthe numeric file identifier

Definition at line 86 of file filesystem.hpp.

References readFile().

◆ readFile() [3/3]

Result< FileBuffer > wowlib::fs::FileSystem::readFile ( std::string_view path)
inline

Read a file by client-internal path.

Returns
the file bytes
Parameters
paththe client-internal file path

Definition at line 78 of file filesystem.hpp.

References readFile().

◆ resolve()

FileKey wowlib::fs::FileSystem::resolve ( const FileKey & key) const
Returns
the completed key
Parameters
keythe file identity to complete

Definition at line 133 of file filesystem.cpp.

◆ version()

ClientVersion wowlib::fs::FileSystem::version ( ) const
inline

The client version this filesystem was opened for — the anchor of version-agnostic code (expansion_of, for_version, Table.open).

A static fact of the opened client; remains valid after close().

Definition at line 153 of file filesystem.hpp.

Referenced by FileSystem(), and FileSystem().


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