Engine → Core → native_file_system.h
vfs::native_file_system
| Type | Class |
| Namespace | conjure::core::vfs |
| Include File Path | engine/include/conjure/core/vfs/native_file_system.h |
| Source File Path | engine/src/core/vfs/native_file_system.cpp |
| API ↗ | Files and the virtual file system |
Syntax
Inheritance Hierarchy
vfs::file_system → vfs::native_file_system
Constructors
| Access | Signature | Description |
|---|---|---|
| public | explicit native_file_system(
std::filesystem::path rootPath,
bool readOnly = false); | Wraps rootPath. The directory does not have to exist yet: the first write creates it. A read-only instance rejects every mutating call. |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~native_file_system() override; |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mReadOnly | bool | false | |
| private | mRoot | std::filesystem::path | {} |
Functions
Public
create_directories
create_directories[[nodiscard]] result<void> create_directories(
std::string_view path) override;enumerate
enumerate[[nodiscard]] result<void> enumerate(
std::string_view directory,
enumerate_flags flags,
const enumerate_callback &callback) override;is_read_only
is_read_only[[nodiscard]] bool is_read_only() const noexcept override;read_file
read_file[[nodiscard]] result<std::vector<std::byte>> read_file(
std::string_view path) override;remove
remove[[nodiscard]] result<void> remove(
std::string_view path) override;remove_all
remove_all[[nodiscard]] result<void> remove_all(
std::string_view path) override;rename
rename[[nodiscard]] result<void> rename(
std::string_view from,
std::string_view to) override;root
root[[nodiscard]] const std::filesystem::path &root() const noexcept;The root every path is resolved against, as given to the constructor (lexically normalised, without a trailing separator).
to_native
to_native[[nodiscard]] result<std::filesystem::path> to_native(
std::string_view path) const;The on-disk path a backend-relative path maps to; "" and "/" map to the root itself. Checked exactly like every file method: a path that would leave the root ("../x", "/../x", "C:/x", "//server/x") is PERMISSION_DENIED, so the result is always the root or below it and is safe to hand to code outside the file system (a process, a dynamic library). Purely lexical: the path does not have to exist, and a read-only instance maps paths like any other. On Windows a path beyond the classic length limit, or one with a name that is not portable (path_utils::is_portable_name), comes back in the extended-length form, the one that addresses it.
write_file
write_file[[nodiscard]] result<void> write_file(
std::string_view path,
std::span<const std::byte> data) override;write_file_atomic
write_file_atomic[[nodiscard]] result<void> write_file_atomic(
std::string_view path,
std::span<const std::byte> data) override;Private
native_path_of
native_path_of[[nodiscard]] std::filesystem::path native_path_of(
std::string_view relative) const;Maps a path that resolve_backend_path already accepted (normalised, relative, inside the root) to its on-disk path. Unchecked: only the checked entry points call it.
resolve
resolve[[nodiscard]] result<std::filesystem::path> resolve(
std::string_view path) const;resolve_writable
resolve_writable[[nodiscard]] result<std::filesystem::path> resolve_writable(
std::string_view path) const;write_bytes
write_bytes[[nodiscard]] result<void> write_bytes(
const std::filesystem::path &nativePath,
std::string_view displayPath,
std::span<const std::byte> data) const;