Max OS 0.3
Loading...
Searching...
No Matches
vfsresource.h
Go to the documentation of this file.
1
10#ifndef MAXOS_FILESYSTEM_VFSRESOURCE_H
11#define MAXOS_FILESYSTEM_VFSRESOURCE_H
12
13#include <processes/resource.h>
14#include <filesystem/vfs.h>
15#include <common/buffer.h>
16#include <processes/scheduler.h>
17#include <syscore/include/filesystem/file.h>
18#include <syscore/include/filesystem/directory.h>
19
20namespace MaxOS {
21
22 namespace filesystem {
23
32 class FileResource final : public processes::Resource{
33
34 public:
35 FileResource(const string& name, size_t flags, processes::resource_type_t type);
36 ~FileResource() final;
37
39
40 int read(void* buffer, size_t size, size_t flags) final;
41 int write(const void* buffer, size_t size, size_t flags) final;
42
43 };
44
50
51 private:
52
53 void write_entries(const void* buffer, size_t size) const;
54 [[nodiscard]] size_t entries_size() const;
55
56 public:
57
58 DirectoryResource(const string& name, size_t flags, processes::resource_type_t type);
59 ~DirectoryResource() final;
60
62
63 int read(void* buffer, size_t size, size_t flags) final;
64 int write(const void* buffer, size_t size, size_t flags) final;
65
66 };
67
73
74 private:
75 VirtualFileSystem* m_vfs;
76
77 processes::Resource* open_as_resource(const string& name, Directory* directory);
78 processes::Resource* open_as_resource(const string& name, File* file);
79
80 public:
81
84
85 processes::Resource* get_resource(const string& name) final;
86 processes::Resource* create_resource(const string& name, size_t flags) final;
87
88 };
89
90 }
91}
92
93#endif //MAXOS_FILESYSTEM_VFSRESOURCE_H
Defines a Buffer class for safe memory operations.
A wrapper for a Directory which exposes Directory operations as Resource operations.
Definition vfsresource.h:49
int read(void *buffer, size_t size, size_t flags) final
read from a directory resource
int write(const void *buffer, size_t size, size_t flags) final
write to a directory resource
Directory * directory
The directory that this resource handles & exposes.
Definition vfsresource.h:61
Handles a group of files (directory)
Definition filesystem.h:57
A wrapper for a File which exposes File operations as Resource operations.
Definition vfsresource.h:32
int write(const void *buffer, size_t size, size_t flags) final
write to a file resource
File * file
The file that this resource handles & exposes.
Definition vfsresource.h:38
int read(void *buffer, size_t size, size_t flags) final
read from a file resource
Handles file operations and information.
Definition filesystem.h:31
A resource registry for both Files & Directories.
Definition vfsresource.h:72
processes::Resource * get_resource(const string &name) final
Gets a resource from the registry by name.
processes::Resource * create_resource(const string &name, size_t flags) final
Try to create a new resource with the specified name, will fail if the name is in use.
Combines all the filesystems across the partitions on each disk into a single filesystems and exposes...
Definition vfs.h:25
Manages the creation, retention and destruction of resources of a certain type. Should be subclassed ...
Definition resource.h:54
Represents a generic resource that can be opened, closed, read from and written to.
Definition resource.h:29
string name()
Gets the name of this resource.
Definition resource.cpp:79
resource_type_t type()
Gets the type of this resource.
Definition resource.cpp:88
Defines classes for managing process resources such as files and devices.
::syscore::ResourceType resource_type_t
Alias to make the libsyscore ResourceType accessible here.
Definition resource.h:22
Defines a GlobalScheduler and Scheduler for managing processes and threads.
Defines a Virtual File System (VFS) class for managing multiple filesystems and providing a unified i...