Atlas-Launcher/external/vfs/include/VirtualFileSystem.hpp

49 lines
1.4 KiB
C++

#pragma once
#include <filesystem>
namespace vfs {
/**
* Represent a virtual file system.
* Real directory can be mounted to safely interact with the real file system.
*/
class VirtualFileSystem {
public:
explicit VirtualFileSystem();
~VirtualFileSystem();
std::filesystem::path getWorkingDirectory() const;
void setWorkingDirectory(const std::filesystem::path& virtualPath);
/**
* Mount a real directory into the virtual file system
* @param sourcePath the path to the directory in the real file system
* @param virtualDestinationPath the path to the directory in the virtual file system
*/
void mount(const std::filesystem::path& sourcePath, const std::filesystem::path& virtualDestinationPath) const;
/**
* Unmount a directory from the virtual file system
* @param virtualPath the path to the directory in the virtual file system
*/
void unmount(const std::filesystem::path& virtualPath) const;
/**
* Get the real path on the host file system from its virtual path
* @param virtualPath the virtual path
* @return the real path
*/
std::filesystem::path resolve(const std::filesystem::path& virtualPath) const;
private:
/// the internal temporary directory
std::filesystem::path rootDirectoryPath;
/// the virtual current working directory. Always relative.
std::filesystem::path virtualWorkingDirectory;
};
}