![]() |
galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
|
File System to make managing files easier. More...
#include <VirtualFileSystem.hpp>
Public Member Functions | |
VirtualFileSystem () | |
Constructor. | |
~VirtualFileSystem () | |
Destructor. | |
std::string | read (const std::string &file) |
Read a file. | |
std::vector< std::uint8_t > | read_binary (const std::string &file) |
Read a binary file. | |
bool | write (const std::string &data, const std::string &file) |
Writes a file to disk. | |
bool | write_binary (std::span< std::uint8_t > data, const std::string &file) |
Writes a binary file to disk. | |
bool | write_raw (const void *data, const std::size_t size, const std::string &file) |
Raw data writing. | |
void | mkdir (const std::string &dir) noexcept |
Creates an empty folder in the filesystem relative to the root. | |
void | remove (const std::string &path) noexcept |
Delete a file or folder. | |
bool | exists (const std::string &file) noexcept |
Does the file exist in the vfs. | |
bool | is_dir (const std::string &path) noexcept |
Checks if a file is a folder. | |
std::vector< std::string > | list (const std::string &dir) |
Get assets in an asset folder. | |
void | alert () noexcept |
Trigger a standard filesystem audio alert. | |
void | notification (const std::string &title, const std::string &msg, const DialogIcon icon) noexcept |
Trigger a system notification. | |
int | message_box (const std::string &title, const std::string &msg, const DialogType type, const DialogIcon icon, const DialogButton btn) noexcept |
Opens a platform specific message box. | |
std::string | input_box (const std::string &title, const std::string &msg, const std::string &default_text="", const bool password=false) noexcept |
Opens a platform specific text input box. | |
std::string | open_save_dialog (const std::string &default_filename, const std::vector< const char * > &filters={}) |
Open a save file dialog. | |
std::string | open_file_dialog (const std::vector< const char * > &filters={}, const std::string &def_path="") |
Open a file dialog. | |
std::string | select_folder_dialog (const std::string &def_path="") |
Select a folder using a dialog. | |
std::string | get_file_extension (const std::string &file_name) noexcept |
Get pointer to extension for a filename string. | |
Private Member Functions | |
VirtualFileSystem (const VirtualFileSystem &)=delete | |
Copy constructor. | |
VirtualFileSystem (VirtualFileSystem &&)=delete | |
Move constructor. | |
VirtualFileSystem & | operator= (const VirtualFileSystem &)=delete |
Copy assignment operator. | |
VirtualFileSystem & | operator= (VirtualFileSystem &&)=delete |
Move assignment operator. | |
File System to make managing files easier.
Definition at line 26 of file VirtualFileSystem.hpp.
galaxy::fs::VirtualFileSystem::VirtualFileSystem | ( | ) |
Constructor.
Definition at line 32 of file VirtualFileSystem.cpp.
galaxy::fs::VirtualFileSystem::~VirtualFileSystem | ( | ) |
Destructor.
Definition at line 84 of file VirtualFileSystem.cpp.
|
privatedelete |
Copy constructor.
|
privatedelete |
Move constructor.
|
nodiscard |
Read a file.
file | File to read from. |
Definition at line 89 of file VirtualFileSystem.cpp.
|
nodiscard |
Read a binary file.
file | File to read from. |
Definition at line 125 of file VirtualFileSystem.cpp.
|
nodiscard |
Writes a file to disk.
Checks for existing file to overwrite first.
data | Data to write to file. |
file | Path to write to, including path from root. |
Definition at line 161 of file VirtualFileSystem.cpp.
|
nodiscard |
Writes a binary file to disk.
Checks for existing file to overwrite first.
data | Data to write to file. |
file | Path to write to, including path from root. |
Definition at line 166 of file VirtualFileSystem.cpp.
|
nodiscard |
Raw data writing.
data | Data to write to file. |
size | Size of data to write. |
file | Path to write to, including path from root. |
Definition at line 171 of file VirtualFileSystem.cpp.
|
noexcept |
Creates an empty folder in the filesystem relative to the root.
All missing parent directories are also created if they don't exist.
dir | Directory(s) to create. |
Definition at line 203 of file VirtualFileSystem.cpp.
|
noexcept |
Delete a file or folder.
Relative to the root. I.e. "textures/test.png" will become ROOT/textures/test.png.
path | File or folder to delete. |
Definition at line 211 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Does the file exist in the vfs.
file | File to check. |
Definition at line 216 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Checks if a file is a folder.
path | File/folder to check. |
Definition at line 221 of file VirtualFileSystem.cpp.
|
nodiscard |
Get assets in an asset folder.
dir | Directory to fetch assets from. |
Definition at line 226 of file VirtualFileSystem.cpp.
|
noexcept |
Trigger a standard filesystem audio alert.
Definition at line 250 of file VirtualFileSystem.cpp.
|
noexcept |
Trigger a system notification.
title | Notification title. |
msg | Body text of notification. |
icon | Icon to display alongside text. |
Definition at line 255 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Opens a platform specific message box.
title | Notification title. |
msg | Body text of notification. |
type | Type of message box. |
icon | Icon to display alongside text. |
btn | Button to show on message box. |
Definition at line 261 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Opens a platform specific text input box.
title | Notification title. |
msg | Body text of notification. |
default_text | Default text displayed in input box. |
password | True to obscure input. Note that enabling this disables default_text. |
Definition at line 269 of file VirtualFileSystem.cpp.
|
nodiscard |
Open a save file dialog.
default_filename | Default name to save file as. |
filters | List of filters for dialog, i.e. "*.png", "*.jpg", etc. |
Definition at line 275 of file VirtualFileSystem.cpp.
|
nodiscard |
Open a file dialog.
filters | List of filters for dialog, i.e. "*.png", "*.jpg", etc. |
def_path | Default starting path to open dialog at. |
Definition at line 290 of file VirtualFileSystem.cpp.
|
nodiscard |
Select a folder using a dialog.
def_path | Default starting path to open dialog at. |
Definition at line 307 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Get pointer to extension for a filename string.
file_name | File name to parse. |
Definition at line 322 of file VirtualFileSystem.cpp.
|
privatedelete |
Copy assignment operator.
|
privatedelete |
Move assignment operator.