Max OS 0.3
Loading...
Searching...
No Matches
vfs.h
Go to the documentation of this file.
1
10#ifndef MAXOS_FILESYSTEM_VFS_H
11#define MAXOS_FILESYSTEM_VFS_H
12
13#include <common/map.h>
14#include <common/pair.h>
16
17
18namespace MaxOS::filesystem {
19
26
27 private:
29 inline static VirtualFileSystem* s_current_file_system = nullptr;
30
31 public:
34
36
37 void mount_filesystem(FileSystem* filesystem);
38 void mount_filesystem(FileSystem* filesystem, const string& mount_point);
39 void unmount_filesystem(FileSystem* filesystem);
40 void unmount_filesystem(const string& mount_point);
41 void unmount_all();
42
45
46 FileSystem* get_filesystem(const string& mount_point);
47 FileSystem* find_filesystem(string path);
48 string get_relative_path(FileSystem* filesystem, string path);
49
50 Directory* open_directory(const string& path);
51 static Directory* open_directory(Directory* parent, const string& name);
52
53 Directory* create_directory(string path);
54 static Directory* create_directory(Directory* parent, const string& name);
55
56 void delete_directory(string path);
57 static void delete_directory(Directory* parent, const string& name);
58 static void delete_directory(Directory* parent, Directory* directory);
59
60 File* create_file(const string& path);
61 static File* create_file(Directory* parent, const string& name);
62
63 File* open_file(const string& path, size_t offset = 0);
64 static File* open_file(Directory* parent, const string& name, size_t offset = 0);
65
66 void delete_file(const string& path);
67 static void delete_file(Directory* parent, const string& name);
68 };
69}
70
71
72#endif //MAXOS_FILESYSTEM_VFS_H
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Handles a group of files (directory)
Definition filesystem.h:57
Handles the disk operations and file system information.
Definition filesystem.h:96
Handles file operations and information.
Definition filesystem.h:31
Combines all the filesystems across the partitions on each disk into a single filesystems and exposes...
Definition vfs.h:25
~VirtualFileSystem()
Destroy the Virtual File System object and unmount all filesystems.
Definition vfs.cpp:31
void unmount_all()
Remove all mounted filesystems.
Definition vfs.cpp:129
Directory * open_directory(const string &path)
Try to open a directory on the virtual file system and read it's contents.
Definition vfs.cpp:245
FileSystem * root_filesystem()
Get the filesystem mounted at the root.
Definition vfs.cpp:158
FileSystem * get_filesystem(const string &mount_point)
Get a specific filesystem mounted at a given mount point.
Definition vfs.cpp:174
void unmount_filesystem(FileSystem *filesystem)
Remove a filesystem from the virtual file system & delete it.
Definition vfs.cpp:97
void mount_filesystem(FileSystem *filesystem)
Add a filesystem to the virtual file system.
Definition vfs.cpp:55
FileSystem * find_filesystem(string path)
Find the filesystem that is responsible for a given path.
Definition vfs.cpp:191
File * open_file(const string &path, size_t offset=0)
Try to open a file on the virtual file system with a given offset.
Definition vfs.cpp:459
Directory * create_directory(string path)
Attempts to open the parent directory and creates the sub directory at the end of the path.
Definition vfs.cpp:293
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)
Definition vfs.cpp:220
Directory * root_directory()
Get the root directory of the virtual file system.
Definition vfs.cpp:142
void delete_file(const string &path)
Opens a directory on the vfs and deletes the file at the end of the path.
Definition vfs.cpp:499
File * create_file(const string &path)
Attempts to open the parent directory and create the file at the end of the path.
Definition vfs.cpp:425
void delete_directory(string path)
Attempts to open the parent directory and deletes the sub directory at the end of the path.
Definition vfs.cpp:337
static VirtualFileSystem * current_file_system()
Get the active virtual file system.
Definition vfs.cpp:46
VirtualFileSystem()
Construct a new Virtual File System object and set it as the current file system.
Definition vfs.cpp:21
Defines a generic API for a file system, including classes for File, Directory, and FileSystem.
Defines a Map class for storing key-value pairs.
Defines a Pair class for storing two related objects together.