Engine → Core → mount_table.h
vfs::mount_table
| Type | Class |
| Namespace | conjure::core::vfs |
| Include File Path | engine/include/conjure/core/vfs/mount_table.h |
| Source File Path | engine/src/core/vfs/mount_table.cpp |
| API ↗ | Files and the virtual file system |
Syntax
Inheritance Hierarchy
vfs::file_system → vfs::mount_table
Constructors
| Access | Signature | Description |
|---|---|---|
| public | mount_table(); |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~mount_table() override; |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mMounts | std:: | {} | |
| private | mMutex | mutable std::mutex | {} |
Functions
Public
create_directories
create_directories[[nodiscard]] result<void> create_directories(
std::string_view uri) override;enumerate
enumerate[[nodiscard]] result<void> enumerate(
std::string_view directory,
enumerate_flags flags,
const enumerate_callback &callback) override;exists
exists[[nodiscard]] bool exists(
std::string_view uri) override;find_mount
find_mount[[nodiscard]] file_system *find_mount(
std::string_view scheme) const noexcept;The backend bound to a scheme ("assets" or "assets://"), or nullptr. The pointer stays valid until the scheme is unmounted.
is_read_only
is_read_only[[nodiscard]] bool is_read_only() const noexcept override;True when at least one backend is mounted and all of them are read-only.
mount
mount[[nodiscard]] result<void> mount(
std::string_view scheme,
std::shared_ptr<file_system> backend);Binds a scheme ("assets" or "assets://") to a backend. INVALID_ARGUMENT for a null backend, a malformed scheme or a mount table that already contains this one (directly or through other mount tables), ALREADY_EXISTS when the scheme is taken. One backend may be mounted under several schemes.
read_file
read_file[[nodiscard]] result<std::vector<std::byte>> read_file(
std::string_view uri) override;read_text_file
read_text_file[[nodiscard]] result<std::string> read_text_file(
std::string_view uri) override;remove
remove[[nodiscard]] result<void> remove(
std::string_view uri) override;remove_all
remove_all[[nodiscard]] result<void> remove_all(
std::string_view uri) override;rename
rename[[nodiscard]] result<void> rename(
std::string_view from,
std::string_view to) override;When both URIs lead to the same backend, directly or through nested mount tables, it renames (so two schemes over one backend behave like one). Across backends a file is copied and the source removed; a directory is UNSUPPORTED. The base contract's codes still apply there, judged by the backends that store the two files and in the order of a backend's own rename: PERMISSION_DENIED for an escape or a read-only backend at either end, INVALID_ARGUMENT for the root of a backend at either end and for a name at to that is not portable, and only then the lookups: NOT_FOUND for a missing from, ALREADY_EXISTS for a directory at to, NOT_FOUND when the parent of to is missing. All of it is checked before anything is copied. The copy is written atomically. If the source cannot be removed afterwards, a copy that created a new file is removed again, but a file it replaced is not restored.
schemes
schemes[[nodiscard]] std::vector<std::string> schemes() const;Every mounted scheme in ascending order.
split
split[[nodiscard]] static result<std::pair<std::string_view, std::string_view>> split(
std::string_view uri);Splits "scheme://path" into its two parts ("assets://a/b.png" -> {"assets", "a/b.png"}). INVALID_ARGUMENT when there is no "://" or the scheme is empty or contains characters other than letters, digits, '-', '_', '.' and '+'.
unmount
unmount[[nodiscard]] result<void> unmount(
std::string_view scheme);Removes a binding. NOT_FOUND when the scheme is not mounted.
write_file
write_file[[nodiscard]] result<void> write_file(
std::string_view uri,
std::span<const std::byte> data) override;write_file_atomic
write_file_atomic[[nodiscard]] result<void> write_file_atomic(
std::string_view uri,
std::span<const std::byte> data) override;Private
contains
contains[[nodiscard]] bool contains(
const file_system &backend) const;find_shared
find_sharedroute
route[[nodiscard]] result<route_target> route(
std::string_view uri) const;route_to_storage
route_to_storage[[nodiscard]] static result<route_target> route_to_storage(
route_target target);snapshot_backends
snapshot_backends[[nodiscard]] std::vector<std::shared_ptr<file_system>> snapshot_backends() const;