wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
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
16
#include <
wowlib/core/buffer.hpp
>
17
#include <
wowlib/core/client_version.hpp
>
18
#include <
wowlib/core/error.hpp
>
19
#include <
wowlib/core/file_key.hpp
>
20
21
namespace
wowlib::fs
{
37
class
CascStorage
{
38
public
:
40
struct
Options
{
41
std::filesystem::path
clientRoot
;
42
std::string
product
=
"wow"
;
43
Locale
locale
=
Locale::enUS
;
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
;
62
CascStorage
&
operator=
(
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
83
Result<FileBuffer>
readFile
(
const
FileKey
& key);
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
113
Result<std::vector<FileDataID>
>
enumerateFdids
();
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
}
buffer.hpp
The owning byte buffer file contents are read into.
wowlib::fs::CascStorage::CascStorage
CascStorage(const CascStorage &)=delete
wowlib::fs::CascStorage::enumerateFdids
Result< std::vector< FileDataID > > enumerateFdids()
Enumerate every FileDataID the storage holds: entries whose content is locally available and that car...
Definition
casc_storage.cpp:242
wowlib::fs::CascStorage::operator=
CascStorage & operator=(CascStorage &&other) noexcept
Definition
casc_storage.hpp:69
wowlib::fs::CascStorage::kind
static constexpr StorageKind kind()
Definition
casc_storage.hpp:116
wowlib::fs::CascStorage::readFile
Result< FileBuffer > readFile(const FileKey &key)
Read a file into memory.
Definition
casc_storage.cpp:189
wowlib::fs::CascStorage::~CascStorage
~CascStorage()
Definition
casc_storage.hpp:59
wowlib::fs::CascStorage::CascStorage
CascStorage(CascStorage &&other) noexcept
Definition
casc_storage.hpp:64
wowlib::fs::CascStorage::operator=
CascStorage & operator=(const CascStorage &)=delete
wowlib::fs::CascStorage::importKeys
Result< void > importKeys(std::string_view keyList)
Register TACT keys from a text list — the community "KeyName KeyHex" per line format (16 hex nibbles ...
Definition
casc_storage.cpp:233
wowlib::fs::CascStorage::exists
bool exists(const FileKey &key)
Whether the file can be opened (probe open + _close).
Definition
casc_storage.cpp:267
wowlib::fs::CascStorage::open
static Result< CascStorage > open(Options options)
Open the local storage.
Definition
casc_storage.cpp:120
wowlib::fs::CascStorage::addEncryptionKey
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,...
Definition
casc_storage.cpp:221
client_version.hpp
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
error.hpp
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
file_key.hpp
File identity types: the strong FileDataID and the FileKey a read request travels as.
wowlib::fs
Definition
table_core.hpp:46
wowlib::Result
std::expected< T, Error > Result
Every fallible wowlib operation returns Result<T>; bindings translate the error branch into a target-...
Definition
error.hpp:100
wowlib::Locale
Locale
Definition
client_version.hpp:285
wowlib::Locale::enUS
@ enUS
Definition
client_version.hpp:286
wowlib::StorageKind
StorageKind
Definition
client_version.hpp:20
wowlib::StorageKind::Casc
@ Casc
WoD+ retail and all Classic clients, CascLib.
Definition
client_version.hpp:22
wowlib::FileKey
Definition
file_key.hpp:26
wowlib::fs::CascStorage::Options
What to open and how.
Definition
casc_storage.hpp:40
wowlib::fs::CascStorage::Options::locale
Locale locale
Locale mask for content selection.
Definition
casc_storage.hpp:43
wowlib::fs::CascStorage::Options::clientRoot
std::filesystem::path clientRoot
Client install root (parent of Data/).
Definition
casc_storage.hpp:41
wowlib::fs::CascStorage::Options::product
std::string product
TACT product code.
Definition
casc_storage.hpp:42
wowlib::fs::CascStorage::Options::build
std::optional< std::uint32_t > build
Preferred client build; orders the build-config candidates when a repack without ....
Definition
casc_storage.hpp:44
src
wowlib
fs
casc
casc_storage.hpp
Generated by
1.17.0