|
wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
|
MPQ chain storage. More...
#include <wowlib/fs/mpq/mpq_storage.hpp>
Classes | |
| struct | Options |
| What to open and how. More... | |
| struct | OpenedArchive |
| One opened member of the chain, for introspection and tests. More... | |
Public Member Functions | |
| ~MpqStorage () | |
| MpqStorage (const MpqStorage &)=delete | |
| MpqStorage & | operator= (const MpqStorage &)=delete |
| MpqStorage (MpqStorage &&other) noexcept | |
| MpqStorage & | operator= (MpqStorage &&other) noexcept |
| Result< FileBuffer > | readFile (const FileKey &key) |
| Read a file into memory. | |
| bool | exists (const FileKey &key) |
| Whether the file exists in any archive of the chain. | |
| Result< std::vector< std::string > > | enumeratePaths () |
| Enumerate every file path reachable through the chain: the members of each archive (named by its internal listfile, loaded on demand — the archives themselves open with MPQ_OPEN_NO_LISTFILE) plus the loose-dir members, canonicalized, deduplicated across the chain and sorted. | |
| std::span< const OpenedArchive > | archives () const |
| Locale | locale () const |
Static Public Member Functions | |
| static Result< MpqStorage > | open (Options options) |
| Expand the version's chain and open every archive present on disk. | |
| static constexpr StorageKind | kind () |
MPQ chain storage.
Opens every member of the version's chain — a StormLib archive, or a directory of loose files standing in for one — and resolves reads through them in reverse load order (last loaded wins), which replicates the client's patch override semantics.
RAII: open() — the only way to obtain an instance — returns a fully open storage, so a constructed MpqStorage is an open one. The destructor (and move-assignment onto an open storage) closes every archive; the only not-open state C++ can hold is a moved-from storage, which is empty and safe to destroy.
Thread safety: reads lock only the archive currently probed (one mutex per archive), so reads of different archives proceed in parallel. StormLib mutates internal state even on lookups, hence probing locks too.
Definition at line 37 of file mpq_storage.hpp.
|
inline |
Definition at line 52 of file mpq_storage.hpp.
|
delete |
References MpqStorage().
Referenced by MpqStorage(), MpqStorage(), open(), operator=(), and operator=().
|
inlinenoexcept |
Definition at line 57 of file mpq_storage.hpp.
References MpqStorage().
|
inline |
Definition at line 118 of file mpq_storage.hpp.
| Result< std::vector< std::string > > wowlib::fs::MpqStorage::enumeratePaths | ( | ) |
Enumerate every file path reachable through the chain: the members of each archive (named by its internal listfile, loaded on demand — the archives themselves open with MPQ_OPEN_NO_LISTFILE) plus the loose-dir members, canonicalized, deduplicated across the chain and sorted.
Best-effort by design: an archive that cannot enumerate (no internal listfile) is skipped silently, as are StormLib's metadata pseudo-files and the nameless hash-table placeholders — a partial listing is more useful than none.
Definition at line 245 of file mpq_storage.cpp.
References wowlib::makeError(), wowlib::normalizePath(), and wowlib::StorageNotOpen.
| bool wowlib::fs::MpqStorage::exists | ( | const FileKey & | key | ) |
Whether the file exists in any archive of the chain.
| key | the file identity (path required). |
Definition at line 220 of file mpq_storage.cpp.
References wowlib::FileKey::path.
|
inlinestaticconstexpr |
Definition at line 93 of file mpq_storage.hpp.
References wowlib::Mpq.
|
inline |
Definition at line 121 of file mpq_storage.hpp.
|
static |
Expand the version's chain and open every archive present on disk.
| options | what to open. |
Definition at line 52 of file mpq_storage.cpp.
References MpqStorage().
Referenced by wowlib::fs::FileSystem::open().
|
delete |
References MpqStorage().
|
inlinenoexcept |
Definition at line 60 of file mpq_storage.hpp.
References MpqStorage().
| Result< FileBuffer > wowlib::fs::MpqStorage::readFile | ( | const FileKey & | key | ) |
Read a file into memory.
MPQ storage is path-addressed: a key without a path fails with FdidNotResolvable (resolve ids through a listfile in the composition layer first).
| key | the file identity. |
Definition at line 162 of file mpq_storage.cpp.
References wowlib::BackendError, wowlib::FdidNotResolvable, wowlib::FileNotFound, wowlib::makeError(), wowlib::FileKey::path, and wowlib::StorageNotOpen.