wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::fs::ClientFileSystem< Backend, Listfile > Class Template Reference

The static composition of one client's file access: storage backend + listfile database + optional project-directory overlay. More...

#include <wowlib/fs/client_filesystem.hpp>

Public Member Functions

 ClientFileSystem (Backend backend, Listfile listfile={}, std::optional< ProjectDirectory > project=std::nullopt)
 Compose from ready components (backends are open by construction).
Result< FileBuffer > readFile (const FileKey &key)
 Read a file by key.
bool exists (const FileKey &key)
 Whether a file is reachable in the overlay or the storage.
FileKey resolve (const FileKey &key) const
 Fill the missing half of a key (path or FileDataID) from the listfile, best-effort.
Result< FileDataID > addFile (std::string_view path, std::span< const std::byte > content)
 Add (or overwrite) a file in the project directory.
Backend & backend ()
Listfile & listfile ()
ProjectDirectory * project ()

Static Public Member Functions

static constexpr StorageKind kind ()

Detailed Description

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
class wowlib::fs::ClientFileSystem< Backend, Listfile >

The static composition of one client's file access: storage backend + listfile database + optional project-directory overlay.

Lookup precedence: project directory first (the ultimate patch), then the client storage.

Template Parameters
Backendthe storage backend (MpqStorage or CascStorage).
Listfilethe path<->FileDataID database provider.

Definition at line 28 of file client_filesystem.hpp.

Constructor & Destructor Documentation

◆ ClientFileSystem()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
wowlib::fs::ClientFileSystem< Backend, Listfile >::ClientFileSystem ( Backend backend,
Listfile listfile = {},
std::optional< ProjectDirectory > project = std::nullopt )
inline

Compose from ready components (backends are open by construction).

Parameters
backendthe open storage backend.
listfilethe listfile database.
projectthe overlay, if any.

Definition at line 34 of file client_filesystem.hpp.

Member Function Documentation

◆ addFile()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
Result< FileDataID > wowlib::fs::ClientFileSystem< Backend, Listfile >::addFile ( std::string_view path,
std::span< const std::byte > content )
inline

Add (or overwrite) a file in the project directory.

On a CASC-era client a new path is also registered in the listfile, allocating a custom FileDataID (the provider persists it to its working file).

Parameters
paththe client-internal path of the file.
contentthe file contents.
Returns
the file's FileDataID (0 on MPQ-era clients, which have no id space).

Definition at line 76 of file client_filesystem.hpp.

◆ backend()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
Backend & wowlib::fs::ClientFileSystem< Backend, Listfile >::backend ( )
inline
Returns
the storage backend.

Definition at line 94 of file client_filesystem.hpp.

◆ exists()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
bool wowlib::fs::ClientFileSystem< Backend, Listfile >::exists ( const FileKey & key)
inline

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

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

Definition at line 52 of file client_filesystem.hpp.

◆ kind()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
constexpr StorageKind wowlib::fs::ClientFileSystem< Backend, Listfile >::kind ( )
inlinestaticconstexpr
Returns
the storage technology backing this composition.

Definition at line 91 of file client_filesystem.hpp.

◆ listfile()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
Listfile & wowlib::fs::ClientFileSystem< Backend, Listfile >::listfile ( )
inline
Returns
the listfile database.

Definition at line 97 of file client_filesystem.hpp.

◆ project()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
ProjectDirectory * wowlib::fs::ClientFileSystem< Backend, Listfile >::project ( )
inline
Returns
the project-directory overlay, or nullptr if none is set.

Definition at line 100 of file client_filesystem.hpp.

◆ readFile()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
Result< FileBuffer > wowlib::fs::ClientFileSystem< Backend, Listfile >::readFile ( const FileKey & key)
inline

Read a file by key.

Missing identity halves are filled from the listfile; the project directory wins over the client storage.

Parameters
keythe file identity (path, id, or both).
Returns
the file bytes.

Definition at line 41 of file client_filesystem.hpp.

◆ resolve()

template<StorageBackend Backend, ListfileProvider Listfile = NullListfile>
FileKey wowlib::fs::ClientFileSystem< Backend, Listfile >::resolve ( const FileKey & key) const
inline

Fill the missing half of a key (path or FileDataID) from the listfile, best-effort.

Parameters
keythe file identity.
Returns
the completed key (unchanged parts preserved).

Definition at line 62 of file client_filesystem.hpp.

Referenced by wowlib::fs::ClientFileSystem< MpqStorage, NullListfile >::exists(), and wowlib::fs::ClientFileSystem< MpqStorage, NullListfile >::readFile().


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