galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::fs::VirtualFileSystem Class Referencefinal

File System to make managing files easier. More...

#include <VirtualFileSystem.hpp>

+ Collaboration diagram for galaxy::fs::VirtualFileSystem:

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.
 
VirtualFileSystemoperator= (const VirtualFileSystem &)=delete
 Copy assignment operator.
 
VirtualFileSystemoperator= (VirtualFileSystem &&)=delete
 Move assignment operator.
 

Detailed Description

File System to make managing files easier.

Definition at line 26 of file VirtualFileSystem.hpp.

Constructor & Destructor Documentation

◆ VirtualFileSystem() [1/3]

galaxy::fs::VirtualFileSystem::VirtualFileSystem ( )

Constructor.

Definition at line 32 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:

◆ ~VirtualFileSystem()

galaxy::fs::VirtualFileSystem::~VirtualFileSystem ( )

Destructor.

Definition at line 84 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:

◆ VirtualFileSystem() [2/3]

galaxy::fs::VirtualFileSystem::VirtualFileSystem ( const VirtualFileSystem & )
privatedelete

Copy constructor.

◆ VirtualFileSystem() [3/3]

galaxy::fs::VirtualFileSystem::VirtualFileSystem ( VirtualFileSystem && )
privatedelete

Move constructor.

Member Function Documentation

◆ read()

std::string galaxy::fs::VirtualFileSystem::read ( const std::string & file)
nodiscard

Read a file.

Parameters
fileFile to read from.
Returns
Buffer containing read data.

Definition at line 89 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read_binary()

std::vector< std::uint8_t > galaxy::fs::VirtualFileSystem::read_binary ( const std::string & file)
nodiscard

Read a binary file.

Parameters
fileFile to read from.
Returns
Buffer containing read data.

Definition at line 125 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write()

bool galaxy::fs::VirtualFileSystem::write ( const std::string & data,
const std::string & file )
nodiscard

Writes a file to disk.

Checks for existing file to overwrite first.

Parameters
dataData to write to file.
filePath to write to, including path from root.
Returns
True if successful.

Definition at line 161 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_binary()

bool galaxy::fs::VirtualFileSystem::write_binary ( std::span< std::uint8_t > data,
const std::string & file )
nodiscard

Writes a binary file to disk.

Checks for existing file to overwrite first.

Parameters
dataData to write to file.
filePath to write to, including path from root.
Returns
True if successful.

Definition at line 166 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write_raw()

bool galaxy::fs::VirtualFileSystem::write_raw ( const void * data,
const std::size_t size,
const std::string & file )
nodiscard

Raw data writing.

Parameters
dataData to write to file.
sizeSize of data to write.
filePath to write to, including path from root.
Returns
True if successful.

Definition at line 171 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mkdir()

void galaxy::fs::VirtualFileSystem::mkdir ( const std::string & dir)
noexcept

Creates an empty folder in the filesystem relative to the root.

All missing parent directories are also created if they don't exist.

Parameters
dirDirectory(s) to create.

Definition at line 203 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

void galaxy::fs::VirtualFileSystem::remove ( const std::string & path)
noexcept

Delete a file or folder.

Relative to the root. I.e. "textures/test.png" will become ROOT/textures/test.png.

Parameters
pathFile or folder to delete.

Definition at line 211 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exists()

bool galaxy::fs::VirtualFileSystem::exists ( const std::string & file)
nodiscardnoexcept

Does the file exist in the vfs.

Parameters
fileFile to check.
Returns
True if file exists.

Definition at line 216 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ is_dir()

bool galaxy::fs::VirtualFileSystem::is_dir ( const std::string & path)
nodiscardnoexcept

Checks if a file is a folder.

Parameters
pathFile/folder to check.
Returns
True if directory.

Definition at line 221 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ list()

std::vector< std::string > galaxy::fs::VirtualFileSystem::list ( const std::string & dir)
nodiscard

Get assets in an asset folder.

Parameters
dirDirectory to fetch assets from.
Returns
List of assets in directory.

Definition at line 226 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alert()

void galaxy::fs::VirtualFileSystem::alert ( )
noexcept

Trigger a standard filesystem audio alert.

Definition at line 250 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ notification()

void galaxy::fs::VirtualFileSystem::notification ( const std::string & title,
const std::string & msg,
const DialogIcon icon )
noexcept

Trigger a system notification.

Parameters
titleNotification title.
msgBody text of notification.
iconIcon to display alongside text.

Definition at line 255 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ message_box()

int galaxy::fs::VirtualFileSystem::message_box ( const std::string & title,
const std::string & msg,
const DialogType type,
const DialogIcon icon,
const DialogButton btn )
nodiscardnoexcept

Opens a platform specific message box.

Parameters
titleNotification title.
msgBody text of notification.
typeType of message box.
iconIcon to display alongside text.
btnButton to show on message box.
Returns
Integer with outcome. 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel.

Definition at line 261 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ input_box()

std::string galaxy::fs::VirtualFileSystem::input_box ( const std::string & title,
const std::string & msg,
const std::string & default_text = "",
const bool password = false )
nodiscardnoexcept

Opens a platform specific text input box.

Parameters
titleNotification title.
msgBody text of notification.
default_textDefault text displayed in input box.
passwordTrue to obscure input. Note that enabling this disables default_text.
Returns
Input as a string.

Definition at line 269 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ open_save_dialog()

std::string galaxy::fs::VirtualFileSystem::open_save_dialog ( const std::string & default_filename,
const std::vector< const char * > & filters = {} )
nodiscard

Open a save file dialog.

Parameters
default_filenameDefault name to save file as.
filtersList of filters for dialog, i.e. "*.png", "*.jpg", etc.
Returns
String with path, empty if error.

Definition at line 275 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ open_file_dialog()

std::string galaxy::fs::VirtualFileSystem::open_file_dialog ( const std::vector< const char * > & filters = {},
const std::string & def_path = "" )
nodiscard

Open a file dialog.

Parameters
filtersList of filters for dialog, i.e. "*.png", "*.jpg", etc.
def_pathDefault starting path to open dialog at.
Returns
String with path, empty if error.

Definition at line 290 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select_folder_dialog()

std::string galaxy::fs::VirtualFileSystem::select_folder_dialog ( const std::string & def_path = "")
nodiscard

Select a folder using a dialog.

Parameters
def_pathDefault starting path to open dialog at.
Returns
String with path, empty if error.

Definition at line 307 of file VirtualFileSystem.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_file_extension()

std::string galaxy::fs::VirtualFileSystem::get_file_extension ( const std::string & file_name)
nodiscardnoexcept

Get pointer to extension for a filename string.

Parameters
file_nameFile name to parse.
Returns
File extension, including dot.

Definition at line 322 of file VirtualFileSystem.cpp.

+ Here is the caller graph for this function:

◆ operator=() [1/2]

VirtualFileSystem & galaxy::fs::VirtualFileSystem::operator= ( const VirtualFileSystem & )
privatedelete

Copy assignment operator.

◆ operator=() [2/2]

VirtualFileSystem & galaxy::fs::VirtualFileSystem::operator= ( VirtualFileSystem && )
privatedelete

Move assignment operator.


The documentation for this class was generated from the following files: