#pragma once #include #include namespace rvfs { /** * Represent a virtual restricted file system. * Real directory can be mounted to safely interact with the real file system. */ class RestrictedVirtualFileSystem { public: explicit RestrictedVirtualFileSystem(); /** * Get all the mounted directories with their path in the virtual file system and in the real file system * @return all the mounted directories with their path in the virtual file system and in the real file system */ QMap getMountedDirectories(); /** * Mount a real directory into the virtual file system * @param destination the path to the directory in the virtual file system * @param source the path to the directory in the real file system */ void mountDirectory(const QDir& destination, const QDir& source); /** * Unmount a directory from the virtual file system * @param destination the path to the directory in the virtual file system */ void unmountDirectory(const QDir& destination); /** * Get the current working directory in the virtual file system * @return the current working directory in the virtual file system */ QDir getWorkingDirectory(); /** * Change the current working directory in the virtual file system * @param path path to the new virtual working directory */ void setWorkingDirectory(const QDir& path); /** * Resolve a path inside the virtual file system into a path in the real file system * @param path the path in the virtual file system * @return the matching path in the real file system */ QString resolvePath(QString path); private: /// the current working directory QDir workingDirectory; /// store the path in the virtual file system of a directory in the real file system QMap mounts; }; }