wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::fs::ProjectDirectory Class Reference

A local directory acting as the ultimate patch: files here override every client archive, and new files are added here. More...

#include <wowlib/fs/project_directory.hpp>

Public Member Functions

 ProjectDirectory ()=default
std::optional< std::filesystem::path > resolve (std::string_view path) const
 The real on-disk location of a client-internal path, if the overlay carries it.
bool exists (std::string_view path) const
 Whether the overlay carries a file.
Result< FileBuffer > read (std::string_view path) const
 Read an overlay file into memory.
Result< void > write (std::string_view path, std::span< const std::byte > content)
 Write (create or overwrite) a file under the overlay, creating intermediate directories, and index it.
void rescan ()
 Rebuild the index from disk, picking up files changed by other tools.
const std::filesystem::path & root () const
std::size_t size () const
 ProjectDirectory (const ProjectDirectory &)=delete
ProjectDirectory & operator= (const ProjectDirectory &)=delete
 ProjectDirectory (ProjectDirectory &&other) noexcept
ProjectDirectory & operator= (ProjectDirectory &&other) noexcept

Static Public Member Functions

static Result< ProjectDirectory > open (std::filesystem::path root)
 Open (and index) a project directory; it is created if missing.

Detailed Description

A local directory acting as the ultimate patch: files here override every client archive, and new files are added here.

Lookups go through an in-memory index keyed by canonical path, so they are case-insensitive regardless of the disk's filesystem and O(1). Not welded — target languages reach it through the FileSystem facade.

Definition at line 25 of file project_directory.hpp.

Constructor & Destructor Documentation

◆ ProjectDirectory() [1/3]

wowlib::fs::ProjectDirectory::ProjectDirectory ( )
default

◆ ProjectDirectory() [2/3]

wowlib::fs::ProjectDirectory::ProjectDirectory ( const ProjectDirectory & )
delete

References ProjectDirectory().

◆ ProjectDirectory() [3/3]

wowlib::fs::ProjectDirectory::ProjectDirectory ( ProjectDirectory && other)
noexcept

Definition at line 14 of file project_directory.cpp.

References ProjectDirectory().

Member Function Documentation

◆ exists()

bool wowlib::fs::ProjectDirectory::exists ( std::string_view path) const

Whether the overlay carries a file.

Parameters
paththe client-internal file path.
Returns
true if present.

Definition at line 73 of file project_directory.cpp.

References resolve().

◆ open()

Result< ProjectDirectory > wowlib::fs::ProjectDirectory::open ( std::filesystem::path root)
static

Open (and index) a project directory; it is created if missing.

Parameters
rootthe directory root.
Returns
the overlay, or IoError.

Definition at line 29 of file project_directory.cpp.

References wowlib::IoError, wowlib::makeError(), ProjectDirectory(), and root().

Referenced by wowlib::fs::FileSystem::open().

◆ operator=() [1/2]

ProjectDirectory & wowlib::fs::ProjectDirectory::operator= ( const ProjectDirectory & )
delete

References ProjectDirectory().

◆ operator=() [2/2]

ProjectDirectory & wowlib::fs::ProjectDirectory::operator= ( ProjectDirectory && other)
noexcept

Definition at line 20 of file project_directory.cpp.

References ProjectDirectory().

◆ read()

Result< FileBuffer > wowlib::fs::ProjectDirectory::read ( std::string_view path) const

Read an overlay file into memory.

Parameters
paththe client-internal file path.
Returns
the bytes, or FileNotFound/IoError.

Definition at line 77 of file project_directory.cpp.

References wowlib::FileNotFound, wowlib::IoError, wowlib::makeError(), wowlib::normalizePath(), and resolve().

◆ rescan()

void wowlib::fs::ProjectDirectory::rescan ( )

Rebuild the index from disk, picking up files changed by other tools.

Definition at line 61 of file project_directory.cpp.

◆ resolve()

std::optional< std::filesystem::path > wowlib::fs::ProjectDirectory::resolve ( std::string_view path) const

The real on-disk location of a client-internal path, if the overlay carries it.

Parameters
paththe client-internal file path.
Returns
the absolute path, or nothing.

Definition at line 66 of file project_directory.cpp.

References wowlib::normalizePath().

Referenced by exists(), and read().

◆ root()

const std::filesystem::path & wowlib::fs::ProjectDirectory::root ( ) const
inline
Returns
the directory root (absolute).

Definition at line 61 of file project_directory.hpp.

Referenced by open(), and ProjectDirectory().

◆ size()

std::size_t wowlib::fs::ProjectDirectory::size ( ) const
Returns
the number of indexed files.

Definition at line 122 of file project_directory.cpp.

◆ write()

Result< void > wowlib::fs::ProjectDirectory::write ( std::string_view path,
std::span< const std::byte > content )

Write (create or overwrite) a file under the overlay, creating intermediate directories, and index it.

Parameters
paththe client-internal file path.
contentthe file contents.
Returns
nothing, or IoError.

Definition at line 96 of file project_directory.cpp.

References wowlib::InvalidPath, wowlib::IoError, wowlib::makeError(), wowlib::normalizePath(), and wowlib::toNativeRelative().


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