Skip to content

Engine → Core → native_file_system.h

vfs::native_file_system

Syntax

class CONJURE_API native_file_system final : public file_system

Inheritance Hierarchy

vfs::file_system → vfs::native_file_system

Constructors

AccessSignatureDescription
publicexplicit 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

AccessSignatureDescription
public~native_file_system() override;

Variables

AccessNameTypeDefaultDescription
privatemReadOnlyboolfalse
privatemRootstd::filesystem::path{}

Functions

Public

create_directories

[[nodiscard]] result<void> create_directories(
    std::string_view path) override;

enumerate

[[nodiscard]] result<void> enumerate(
    std::string_view directory,
    enumerate_flags flags,
    const enumerate_callback &callback) override;

is_read_only

[[nodiscard]] bool is_read_only() const noexcept override;

open_read

[[nodiscard]] result<std::unique_ptr<file>> open_read(
    std::string_view path) override;

read_file

[[nodiscard]] result<std::vector<std::byte>> read_file(
    std::string_view path) override;

remove

[[nodiscard]] result<void> remove(
    std::string_view path) override;

remove_all

[[nodiscard]] result<void> remove_all(
    std::string_view path) override;

rename

[[nodiscard]] result<void> rename(
    std::string_view from,
    std::string_view to) override;

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).

stat

[[nodiscard]] result<file_stat> stat(
    std::string_view path) override;

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

[[nodiscard]] result<void> write_file(
    std::string_view path,
    std::span<const std::byte> data) override;

write_file_atomic

[[nodiscard]] result<void> write_file_atomic(
    std::string_view path,
    std::span<const std::byte> data) override;

Private

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

[[nodiscard]] result<std::filesystem::path> resolve(
    std::string_view path) const;

resolve_writable

[[nodiscard]] result<std::filesystem::path> resolve_writable(
    std::string_view path) const;

write_bytes

[[nodiscard]] result<void> write_bytes(
    const std::filesystem::path &nativePath,
    std::string_view displayPath,
    std::span<const std::byte> data) const;