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
Public Member Functions
VirtualFileSystem()=defaultVirtualFileSystem(VirtualFileSystem const &)=deleteVirtualFileSystem(VirtualFileSystem &&)=defaultVirtualFileSystem & operator=(VirtualFileSystem const &)=deleteVirtualFileSystem & operator=(VirtualFileSystem &&)=default~VirtualFileSystem()=defaultBoolResult Mount(str::StringCRef inMntPoint, str::StringCRef inRealPath) noexceptBinds 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.
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) noexceptRemoves a previously registered mount-point/real-path binding.
bool Exists(str::StringCRef inVirtualPath) const noexceptChecks whether a virtual path currently resolves to a real file.
Equivalent to Resolve(inVirtualPath).IsOk().
std::vector< MountInfo > const & ListMounts() const noexceptReturns the currently registered mounts, in resolution order.
bool IsMounted(str::StringCRef inRoot) const noexceptChecks 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 noexceptFinds 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
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.