|
wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
|
The CSV-backed path<->FileDataID database ('fileDataId;filepath' per line, the community listfile format of github.com/wowdev/wow-listfile). More...
#include <wowlib/fs/csv_listfile.hpp>
Public Types | |
| using | Options = CsvListfileOptions |
Public Member Functions | |
| CsvListfile ()=default | |
| std::optional< FileDataID > | pathToFdid (std::string_view path) const |
| Look up the FileDataID of a path (any spelling; canonicalized here). | |
| std::optional< std::string > | fdidToPath (FileDataID fdid) const |
| Look up the canonical path of a FileDataID. | |
| Result< FileDataID > | registerPath (std::string_view path) |
| Allocate a fresh custom FileDataID for a new path, remember the mapping and append it to the working file (in-memory only when the database was not loaded from a file). | |
| bool | contains (std::string_view path) const |
| Whether a path is known. | |
| Result< void > | save () const |
| Rewrite the whole working file canonically (ids ascending). | |
| std::size_t | size () const |
| const std::filesystem::path & | source () const |
| CsvListfile (const CsvListfile &)=delete | |
| CsvListfile & | operator= (const CsvListfile &)=delete |
| CsvListfile (CsvListfile &&other) noexcept | |
| CsvListfile & | operator= (CsvListfile &&other) noexcept |
Static Public Member Functions | |
| static Result< CsvListfile > | load (const std::filesystem::path &csv, Options options={}) |
| Load a listfile CSV; the file becomes the working database that registerPath appends to. | |
The CSV-backed path<->FileDataID database ('fileDataId;filepath' per line, the community listfile format of github.com/wowdev/wow-listfile).
The supplied file is the working database: lookups read from it, registrations append to it, so customizations live right next to the community data and survive reloads. Thread-safe: concurrent lookups, exclusive registration. Not welded — target languages reach it through the FileSystem facade.
Definition at line 37 of file csv_listfile.hpp.
Definition at line 39 of file csv_listfile.hpp.
|
default |
Referenced by CsvListfile(), CsvListfile(), load(), operator=(), and operator=().
|
delete |
References CsvListfile().
|
noexcept |
Definition at line 36 of file csv_listfile.cpp.
References CsvListfile().
| bool wowlib::fs::CsvListfile::contains | ( | std::string_view | path | ) | const |
Whether a path is known.
| path | the client-internal file path. |
Definition at line 140 of file csv_listfile.cpp.
References wowlib::normalizePath().
| std::optional< std::string > wowlib::fs::CsvListfile::fdidToPath | ( | FileDataID | fdid | ) | const |
Look up the canonical path of a FileDataID.
| fdid | the numeric file identifier. |
Definition at line 96 of file csv_listfile.cpp.
References wowlib::FileDataID::value.
|
static |
Load a listfile CSV; the file becomes the working database that registerPath appends to.
Later lines override earlier ones, and the custom-id allocator resumes after the highest custom id present.
| csv | path to the CSV on disk. |
| options | loading options. |
Definition at line 55 of file csv_listfile.cpp.
References CsvListfile(), wowlib::fs::CsvListfileOptions::customFdidStart, wowlib::ListfileIoError, wowlib::makeError(), and wowlib::fs::detail::FdidAllocator::noteExisting().
Referenced by wowlib::fs::FileSystem::open().
|
delete |
References CsvListfile().
|
noexcept |
Definition at line 44 of file csv_listfile.cpp.
References CsvListfile().
| std::optional< FileDataID > wowlib::fs::CsvListfile::pathToFdid | ( | std::string_view | path | ) | const |
Look up the FileDataID of a path (any spelling; canonicalized here).
| path | the client-internal file path. |
Definition at line 89 of file csv_listfile.cpp.
References wowlib::normalizePath().
| Result< FileDataID > wowlib::fs::CsvListfile::registerPath | ( | std::string_view | path | ) |
Allocate a fresh custom FileDataID for a new path, remember the mapping and append it to the working file (in-memory only when the database was not loaded from a file).
Fails with DuplicatePath if the path is already known.
| path | the client-internal path of the new file. |
Definition at line 102 of file csv_listfile.cpp.
References wowlib::DuplicatePath, wowlib::InvalidPath, wowlib::ListfileIoError, wowlib::makeError(), wowlib::normalizePath(), size(), and wowlib::toNativeRelative().
| Result< void > wowlib::fs::CsvListfile::save | ( | ) | const |
Rewrite the whole working file canonically (ids ascending).
Definition at line 146 of file csv_listfile.cpp.
References wowlib::ListfileIoError, wowlib::makeError(), and wowlib::toNativeRelative().
| std::size_t wowlib::fs::CsvListfile::size | ( | ) | const |
Definition at line 169 of file csv_listfile.cpp.
Referenced by registerPath().
|
inline |
Definition at line 81 of file csv_listfile.hpp.