9#ifndef MAXOS_FILESYSTEM_FILESYSTEM_H
10#define MAXOS_FILESYSTEM_FILESYSTEM_H
18#include <syscore/include/filesystem/file.h>
21namespace MaxOS::filesystem {
25 typedef syscore::filesystem::SeekType
SeekType;
47 [[nodiscard]] uint32_t
position()
const;
49 [[nodiscard]]
size_t size()
const;
80 virtual void rename_file(
const string& old_name,
const string& new_name);
107 bool exists(
const string& path);
Defines a Buffer class for safe memory operations.
Wrapper class for a region of bytes in memor in an attempt to add some memory safety....
Stores the left, top, width and height of a rectangle.
Handles a group of files (directory)
common::Vector< Directory * > m_subdirectories
The subdirectories in this directory.
void rename_file(File *file, const string &new_name)
Rename a file in the directory.
string m_name
The name of this directory.
Directory * open_subdirectory(const string &name)
Open a directory in the directory.
virtual Directory * create_subdirectory(const string &name)
Create a directory in the directory.
File * open_file(const string &name)
Open a file in the directory.
virtual void remove_subdirectory(const string &name)
Try to remove a directory in the directory.
size_t size()
Get the size of the directory.
void rename_subdirectory(Directory *directory, const string &new_name)
Rename a subdirectory in the directory.
common::Vector< File * > m_files
The files in this directory.
common::Vector< Directory * > subdirectories()
Get the subdirectories in the directory.
virtual void remove_file(const string &name)
Delete a file in the directory.
common::Vector< File * > files()
Get the files in the directory.
virtual void read_from_disk()
read the directory from the disk
string name()
Get the name of the directory.
virtual File * create_file(const string &name)
Create a file in the directory.
virtual ~Directory()
Destructor for Directory, frees all files and subdirectories.
Handles the disk operations and file system information.
Directory * get_directory(const string &path)
Get the directory at a given path.
bool exists(const string &path)
Check if a path exists on the filesystem.
Directory * m_root_directory
The fist directory in the file system (not be confused with the system root)
virtual ~FileSystem()
Destructor for FileSystem, frees the root directory (Which in turn frees all files and subdirectories...
Directory * root_directory()
Get the directory at "/".
Handles file operations and information.
size_t m_size
The size of the file.
virtual void read(common::buffer_t *data, size_t size)
read data from the file
size_t size() const
Get the size of the file.
string m_name
The name of the file.
void seek(SeekType seek_type, size_t offset)
Seek to a position in the file.
uint32_t position() const
Get where the file is currently at (amount read/write/seeked)
virtual void write(common::buffer_t *data, size_t size)
write data to the file
uint32_t m_offset
The current offset in the file.
string name()
Get the name of the file.
virtual void flush()
Flush the file to the disk.
syscore::filesystem::SeekType SeekType
Seek type for file operations.
uint32_t lba_t
Logical Block Addressing type.
Provides utilities for handling file and directory paths.
Defines a String class for dynamically sized strings with various operations.
Defines a Vector class for dynamically storing an array of elements.