wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
casc_storage.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#include <cstdint>
9#include <filesystem>
10#include <mutex>
11#include <optional>
12#include <span>
13#include <string>
14#include <vector>
15
18#include <wowlib/core/error.hpp>
20
21namespace wowlib::fs {
38 public:
40 struct Options {
41 std::filesystem::path clientRoot;
42 std::string product = "wow";
44 std::optional<std::uint32_t> build;
47 };
48
57 static Result<CascStorage> open(Options options);
58
59 ~CascStorage() { _close(); }
60
61 CascStorage(const CascStorage&) = delete;
63
64 CascStorage(CascStorage&& other) noexcept
65 : _options(std::move(other._options)), _storage(other._storage) {
66 other._storage = nullptr;
67 }
68
69 CascStorage& operator=(CascStorage&& other) noexcept {
70 if (this != &other) {
71 _close();
72 _options = std::move(other._options);
73 _storage = other._storage;
74 other._storage = nullptr;
75 }
76 return *this;
77 }
78
84
93 Result<void> addEncryptionKey(std::uint64_t keyName, std::span<const std::byte, 16> key);
94
100 Result<void> importKeys(std::string_view keyList);
101
105 bool exists(const FileKey& key);
106
114
116 static constexpr StorageKind kind() { return StorageKind::Casc; }
117
118 private:
121 explicit CascStorage(Options options)
122 : _options(std::move(options)) {}
123
127 Result<void> _openStorage();
128
130 void _close() noexcept;
131
133 bool _isOpen() const { return _storage != nullptr; }
134
135 Options _options;
136 void* _storage = nullptr; // CascLib HANDLE
137 mutable std::mutex _mtx;
138 };
139}
The owning byte buffer file contents are read into.
CascStorage(const CascStorage &)=delete
Result< std::vector< FileDataID > > enumerateFdids()
Enumerate every FileDataID the storage holds: entries whose content is locally available and that car...
CascStorage & operator=(CascStorage &&other) noexcept
static constexpr StorageKind kind()
Result< FileBuffer > readFile(const FileKey &key)
Read a file into memory.
CascStorage(CascStorage &&other) noexcept
CascStorage & operator=(const CascStorage &)=delete
Result< void > importKeys(std::string_view keyList)
Register TACT keys from a text list — the community "KeyName KeyHex" per line format (16 hex nibbles ...
bool exists(const FileKey &key)
Whether the file can be opened (probe open + _close).
static Result< CascStorage > open(Options options)
Open the local storage.
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,...
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
File identity types: the strong FileDataID and the FileKey a read request travels as.
std::expected< T, Error > Result
Every fallible wowlib operation returns Result<T>; bindings translate the error branch into a target-...
Definition error.hpp:100
@ Casc
WoD+ retail and all Classic clients, CascLib.
Locale locale
Locale mask for content selection.
std::filesystem::path clientRoot
Client install root (parent of Data/).
std::string product
TACT product code.
std::optional< std::uint32_t > build
Preferred client build; orders the build-config candidates when a repack without ....