![]() |
Max OS 0.3
|
Combines all the filesystems across the partitions on each disk into a single filesystems and exposes a single API to interact with them. More...
#include <vfs.h>
Public Member Functions | |
| VirtualFileSystem () | |
| Construct a new Virtual File System object and set it as the current file system. | |
| ~VirtualFileSystem () | |
| Destroy the Virtual File System object and unmount all filesystems. | |
| void | mount_filesystem (FileSystem *filesystem) |
| Add a filesystem to the virtual file system. | |
| void | mount_filesystem (FileSystem *filesystem, const string &mount_point) |
| Add a filesystem to the virtual file system at a given mount point. | |
| void | unmount_filesystem (FileSystem *filesystem) |
| Remove a filesystem from the virtual file system & delete it. | |
| void | unmount_filesystem (const string &mount_point) |
| Remove a filesystem from the virtual file system. | |
| void | unmount_all () |
| Remove all mounted filesystems. | |
| Directory * | root_directory () |
| Get the root directory of the virtual file system. | |
| 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. | |
| FileSystem * | find_filesystem (string path) |
| Find the filesystem that is responsible for a given 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 * | open_directory (const string &path) |
| Try to open a directory on the virtual file system and read it's contents. | |
| Directory * | create_directory (string path) |
| Attempts to open the parent directory and creates the sub directory 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. | |
| File * | create_file (const string &path) |
| Attempts to open the parent directory and create the file at the end of the 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. | |
| void | delete_file (const string &path) |
| Opens a directory on the vfs and deletes the file at the end of the path. | |
Static Public Member Functions | |
| static VirtualFileSystem * | current_file_system () |
| Get the active virtual file system. | |
| static Directory * | open_directory (Directory *parent, const string &name) |
| Opens a subdirectory from a parent directory. | |
| static Directory * | create_directory (Directory *parent, const string &name) |
| Creates a subdirectory in the specified directory and. | |
| static void | delete_directory (Directory *parent, const string &name) |
| Delete a directory on the virtual file system and it's sub contents. | |
| static void | delete_directory (Directory *parent, Directory *directory) |
| Delete a directory on the virtual file system and it's sub contents. | |
| static File * | create_file (Directory *parent, const string &name) |
| Create a file in a directory. | |
| static File * | open_file (Directory *parent, const string &name, size_t offset=0) |
| Opens a file in a directory with the given offset. | |
| static void | delete_file (Directory *parent, const string &name) |
| Delete a file in the given directory. | |
Combines all the filesystems across the partitions on each disk into a single filesystems and exposes a single API to interact with them.
| VirtualFileSystem::VirtualFileSystem | ( | ) |
| VirtualFileSystem::~VirtualFileSystem | ( | ) |
Destroy the Virtual File System object and unmount all filesystems.
Definition at line 31 of file vfs.cpp.
References unmount_all().
Creates a subdirectory in the specified directory and.
| parent | Where to create the directory |
| name | The name of the new directory |
Definition at line 322 of file vfs.cpp.
References MaxOS::filesystem::Directory::read_from_disk().
Attempts to open the parent directory and creates the sub directory at the end of the path.
| path | The path to the directory |
Definition at line 293 of file vfs.cpp.
References create_directory(), MaxOS::filesystem::Path::file_name(), find_filesystem(), open_directory(), and MaxOS::filesystem::Path::valid().
Referenced by create_directory(), and MaxOS::filesystem::VFSResourceRegistry::create_resource().
Attempts to open the parent directory and create the file at the end of the path.
| path | The path to the file (including the extension) |
Definition at line 425 of file vfs.cpp.
References create_file(), MaxOS::filesystem::Path::file_name(), open_directory(), and MaxOS::filesystem::Path::valid().
Referenced by create_file(), and MaxOS::filesystem::VFSResourceRegistry::create_resource().
|
static |
Get the active virtual file system.
Definition at line 46 of file vfs.cpp.
Referenced by MaxOS::filesystem::partition::MSDOSPartition::mount_partitions().
Delete a directory on the virtual file system and it's sub contents.
| parent | The directory that contains the reference to the directory being deleted |
| name | The name of the directory to delete |
Definition at line 361 of file vfs.cpp.
References delete_directory().
Delete a directory on the virtual file system and it's sub contents.
| parent | The directory that contains the reference to the directory being deleted |
| directory | The the directory to delete |
Definition at line 376 of file vfs.cpp.
References delete_file(), and stack.
Attempts to open the parent directory and deletes the sub directory at the end of the path.
| path | The path to the directory |
Definition at line 337 of file vfs.cpp.
References delete_directory(), MaxOS::filesystem::Path::file_name(), open_directory(), and MaxOS::filesystem::Path::valid().
Referenced by delete_directory(), and delete_directory().
Opens a directory on the vfs and deletes the file at the end of the path.
| path | The path to the file (including the extension) |
Definition at line 499 of file vfs.cpp.
References delete_file(), MaxOS::filesystem::Path::file_name(), open_directory(), and MaxOS::filesystem::Path::valid().
Referenced by delete_directory(), and delete_file().
| FileSystem * VirtualFileSystem::find_filesystem | ( | string | path | ) |
Find the filesystem that is responsible for a given path.
| path | The path to search for |
Definition at line 191 of file vfs.cpp.
Referenced by create_directory(), and open_directory().
| FileSystem * VirtualFileSystem::get_filesystem | ( | const string & | mount_point | ) |
Get a specific filesystem mounted at a given mount point.
| mount_point | The mount point to search for |
Definition at line 174 of file vfs.cpp.
| string VirtualFileSystem::get_relative_path | ( | FileSystem * | filesystem, |
| string | path | ||
| ) |
Get the relative path on a filesystem for a given VFS path (ie remove the mount point)
| filesystem | The filesystem to get the path for |
| path | The path to get the relative path for |
Definition at line 220 of file vfs.cpp.
Referenced by open_directory().
| void VirtualFileSystem::mount_filesystem | ( | FileSystem * | filesystem | ) |
Add a filesystem to the virtual file system.
| filesystem | The filesystem to add |
Definition at line 55 of file vfs.cpp.
References MaxOS::Logger::WARNING().
| void VirtualFileSystem::mount_filesystem | ( | FileSystem * | filesystem, |
| const string & | mount_point | ||
| ) |
Add a filesystem to the virtual file system at a given mount point.
| filesystem | The filesystem to add |
| mount_point | The mount point for the filesystem |
Definition at line 80 of file vfs.cpp.
References MaxOS::Logger::WARNING().
Try to open a directory on the virtual file system and read it's contents.
| path | The path to the directory |
Definition at line 245 of file vfs.cpp.
References MaxOS::filesystem::Path::file_path(), find_filesystem(), get_relative_path(), MaxOS::filesystem::Directory::read_from_disk(), and MaxOS::filesystem::Path::valid().
Referenced by create_directory(), create_file(), delete_directory(), delete_file(), MaxOS::filesystem::VFSResourceRegistry::get_resource(), and open_file().
Opens a subdirectory from a parent directory.
| parent | The parent directory |
| name | The name of the subdirectory |
Try to open a file on the virtual file system with a given offset.
| path | The path to the file (including the extension) |
| offset | The offset to seek to (default = 0) |
Definition at line 459 of file vfs.cpp.
References MaxOS::filesystem::Path::file_name(), open_directory(), open_file(), and MaxOS::filesystem::Path::valid().
Referenced by MaxOS::filesystem::VFSResourceRegistry::get_resource(), and open_file().
|
static |
Opens a file in a directory with the given offset.
| parent | The directory containing the file |
| name | The name of the file to open |
| offset | How far in the file to open (default = 0) |
Definition at line 481 of file vfs.cpp.
| Directory * VirtualFileSystem::root_directory | ( | ) |
Get the root directory of the virtual file system.
Definition at line 142 of file vfs.cpp.
References root_filesystem().
| FileSystem * VirtualFileSystem::root_filesystem | ( | ) |
Get the filesystem mounted at the root.
Definition at line 158 of file vfs.cpp.
Referenced by root_directory().
| void VirtualFileSystem::unmount_all | ( | ) |
Remove all mounted filesystems.
Definition at line 129 of file vfs.cpp.
References unmount_filesystem().
Referenced by ~VirtualFileSystem().
Remove a filesystem from the virtual file system.
| mount_point | Where the filesystem is mounted |
Definition at line 115 of file vfs.cpp.
References unmount_filesystem(), and MaxOS::Logger::WARNING().
| void VirtualFileSystem::unmount_filesystem | ( | FileSystem * | filesystem | ) |
Remove a filesystem from the virtual file system & delete it.
| filesystem | The filesystem to remove |
Definition at line 97 of file vfs.cpp.
Referenced by unmount_all(), and unmount_filesystem().