13using namespace MaxOS::filesystem;
14using namespace MaxOS::common;
24 s_current_file_system =
this;
37 s_current_file_system =
nullptr;
47 return s_current_file_system;
58 if (filesystems.find(filesystem) != filesystems.end()) {
64 string mount_point =
"/filesystem_" + filesystems.size();
67 if (filesystems.size() == 0)
83 if (filesystems.find(filesystem) != filesystems.end()) {
100 if (filesystems.find(filesystem) == filesystems.end())
104 filesystems.erase(filesystem);
118 for(
const auto& filesystem : filesystems)
132 for(
const auto& filesystem : filesystems)
150 return fs->root_directory();
161 if (filesystems.size() == 0)
165 return filesystems.begin()->first;
177 for(
const auto& filesystem : filesystems)
179 return filesystem.first;
198 for (
const auto& filesystem : filesystems) {
223 auto fs = filesystems.find(filesystem);
224 if (
fs == filesystems.end())
308 if (!parent_directory)
347 if (!parent_directory)
364 for (
const auto& directory:
parent->subdirectories())
365 if (directory->name() == name)
387 while (!
stack.empty()) {
449 return parent->create_file(name);
524 parent->remove_file(name);
static Logger WARNING()
Gets active logger set to WARNING level.
Stores the left, top, width and height of a rectangle.
Handles a group of files (directory)
virtual void read_from_disk()
read the directory from the disk
Handles the disk operations and file system information.
Handles file operations and information.
static bool valid(const string &path)
Check if a path is valid.
static string file_name(const string &path)
Get the file name component of a path if it exists or an empty string.
static string file_path(const string &path)
Finds the path to the directory the file is in.
Combines all the filesystems across the partitions on each disk into a single filesystems and exposes...
~VirtualFileSystem()
Destroy the Virtual File System object and unmount all filesystems.
void unmount_all()
Remove all mounted filesystems.
Directory * open_directory(const string &path)
Try to open a directory on the virtual file system and read it's contents.
FileSystem * root_filesystem()
Get the filesystem mounted at the root.
FileSystem * get_filesystem(const string &mount_point)
Get a specific filesystem mounted at a given mount point.
void unmount_filesystem(FileSystem *filesystem)
Remove a filesystem from the virtual file system & delete it.
void mount_filesystem(FileSystem *filesystem)
Add a filesystem to the virtual file system.
FileSystem * find_filesystem(string path)
Find the filesystem that is responsible for a given path.
File * open_file(const string &path, size_t offset=0)
Try to open a file on the virtual file system with a given offset.
Directory * create_directory(string path)
Attempts to open the parent directory and creates the sub directory at the end of the path.
string get_relative_path(FileSystem *filesystem, string path)
Get the relative path on a filesystem for a given VFS path (ie remove the mount point)
Directory * root_directory()
Get the root directory of the virtual file system.
void delete_file(const string &path)
Opens a directory on the vfs and deletes the file at the end of the path.
File * create_file(const string &path)
Attempts to open the parent directory and create the file at the end of the path.
void delete_directory(string path)
Attempts to open the parent directory and deletes the sub directory at the end of the path.
static VirtualFileSystem * current_file_system()
Get the active virtual file system.
VirtualFileSystem()
Construct a new Virtual File System object and set it as the current file system.
uint64_t stack[]
The stack setup for the core in loader.s.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
Defines a Virtual File System (VFS) class for managing multiple filesystems and providing a unified i...