13using namespace MaxOS::filesystem;
14using namespace MaxOS::common;
16File::File() =
default;
18File::~File() =
default;
58 case SeekType::CURRENT:
95Directory::Directory() =
default;
138 if (file->name() ==
name)
228 size += file->size();
254 ASSERT(
false,
"not implemented");
277 ASSERT(
false,
"not implemented");
280FileSystem::FileSystem() =
default;
354 return directory->
open_file(file_name) !=
nullptr;
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.
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.
static string file_name(const string &path)
Get the file name component of a path if it exists or an empty string.
static string top_directory(const string &path)
Get the top directory of a path.
static string file_path(const string &path)
Finds the path to the directory the file is in.
Defines a generic API for a file system, including classes for File, Directory, and FileSystem.
syscore::filesystem::SeekType SeekType
Seek type for file operations.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
#define ASSERT(condition, format,...)
If the specified condition is not met then the kernel will crash with the specified message.