← API Reference Class

asge::filesystem::VirtualFileSystem

Maps virtual asset paths onto real on-disk directories.

#include <VirtualFileSystem.hpp>

A mount table + resolver sitting on top of std::filesystem: Mount() binds a virtual root (e.g. "textures") to a real directory, and Resolve() turns a virtual path (e.g. "textures/hero.png") into the real path of the first registered mount whose target directory actually contains that file. It does no I/O of its own beyond that lookup — callers still read the resolved path through the normal FileIO functions.

Private Attributes

#std::vector< MountInfo > m_Mounts {}private

Public Member Functions

#VirtualFileSystem()=default
#VirtualFileSystem(VirtualFileSystem const &)=delete
#VirtualFileSystem(VirtualFileSystem &&)=default
#VirtualFileSystem & operator=(VirtualFileSystem const &)=delete
#VirtualFileSystem & operator=(VirtualFileSystem &&)=default
#~VirtualFileSystem()=default
#BoolResult Mount(str::StringCRef inMntPoint, str::StringCRef inRealPath) noexcept

Binds a virtual mount point to a real directory.

inRealPath must already exist and be a directory; it is canonicalized and inMntPoint normalized before being recorded, so equivalent forms (slashes, ./.., relative vs. absolute) collapse onto the same entry instead of registering a duplicate mount.

#Result< Path > Resolve(str::StringCRef inVirtualPath) const noexcept

Resolves a virtual path to the real path it currently maps to.

Tries every mount whose virtual root prefixes inVirtualPath, in the order they were registered, and returns the real path of the first one whose target directory actually contains the remainder. A virtual path containing a .. segment is rejected before any mount is tried.

#BoolResult Unmount(str::StringCRef inMntPoint, str::StringCRef inRealPath) noexcept

Removes a previously registered mount-point/real-path binding.

#bool Exists(str::StringCRef inVirtualPath) const noexcept

Checks whether a virtual path currently resolves to a real file.

Equivalent to Resolve(inVirtualPath).IsOk().

#std::vector< MountInfo > const & ListMounts() const noexcept

Returns the currently registered mounts, in resolution order.

#bool IsMounted(str::StringCRef inRoot) const noexcept

Checks whether inRoot is currently a registered mount point.

inRoot is normalized the same way as a Mount() call's mount point.

#Result< str::String > ToVirtualPath(Path const &inRealPath) const noexcept

Finds a mount whose real directory contains inRealPath and returns the corresponding virtual path.

Tries every mount in registration order, like Resolve() does in reverse; a path that only reaches a mount's directory by escaping it via .. doesn't count as contained. inRealPath does not need to exist. Returns a VfsError::NotMounted error if no mount contains it.

Static Public Member Functions

#static SplitPath SplitRoot(str::StringCRef inVirtualPath) noexcept

Splits a virtual path into its root and the remainder after it — the same split Resolve() does internally to find a matching mount, exposed for callers that just need the root.

Normalizes inVirtualPath first, same as Mount()/Resolve(), so equivalent forms (slashes, leading/trailing whitespace) split the same.