File System to make managing files easier. More...
#include <VirtualFileSystem.hpp>
Public Member Functions | |
| VirtualFileSystem () noexcept | |
| Constructor. | |
| ~VirtualFileSystem () noexcept | |
| 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. | |
| std::optional< ray::Image > | load_ray_image (const std::string &filename) noexcept |
| Load an image from VFS. You must manually free the data after. | |
| std::optional< ray::Image > | load_ray_image_anim (const std::string &filename, int *frames) noexcept |
| Load an animated image from VFS (e.g. GIF). You must manually free the data after. | |
| std::optional< ray::Texture2D > | load_ray_texture (const std::string &filename) noexcept |
| Load a texture from VFS. You must manually free the data after. | |
| std::optional< ray::Wave > | load_ray_wave (const std::string &filename) noexcept |
| Load wave data from VFS. You must manually free the data after. | |
| std::optional< ray::Music > | load_ray_music_stream (const std::string &filename) noexcept |
| Load module music from VFS. You must manually free the data after. | |
| std::optional< ray::Font > | load_ray_font (const std::string &filename, int font_size, std::span< int > font_chars) noexcept |
| Load font from VFS. You must manually free the data after. | |
| 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. | |
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.
|
noexcept |
Constructor.
Definition at line 30 of file VirtualFileSystem.cpp.
|
noexcept |
Destructor.
Definition at line 81 of file VirtualFileSystem.cpp.
|
privatedelete |
Copy constructor.
|
privatedelete |
Move constructor.
|
nodiscard |
Read a file.
| file | File to read from. |
Definition at line 86 of file VirtualFileSystem.cpp.
|
nodiscard |
Read a binary file.
| file | File to read from. |
Definition at line 122 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 158 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 163 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 168 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load an image from VFS. You must manually free the data after.
| filename | The filename to load from the search paths. |
Definition at line 200 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load an animated image from VFS (e.g. GIF). You must manually free the data after.
| filename | The filename to load from the search paths. |
| frames | Set to the number of frames decoded on success. |
Definition at line 231 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load a texture from VFS. You must manually free the data after.
| fileName | The filename to load from the search paths. |
Definition at line 262 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load wave data from VFS. You must manually free the data after.
| filename | The file name to load from the PhysFS mount paths. |
Definition at line 286 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load module music from VFS. You must manually free the data after.
| filename | The file name to load from the PhysFS mount paths. |
Definition at line 317 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Load font from VFS. You must manually free the data after.
| filename | The file name to load from the PhysFS mount paths. |
| font_size | Size of the font. |
| font_chars | Characters to load. |
Definition at line 348 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 386 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 394 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Does the file exist in the vfs.
| file | File to check. |
Definition at line 399 of file VirtualFileSystem.cpp.
|
nodiscardnoexcept |
Checks if a file is a folder.
| path | File/folder to check. |
Definition at line 404 of file VirtualFileSystem.cpp.
|
nodiscard |
Get assets in an asset folder.
| dir | Directory to fetch assets from. |
Definition at line 409 of file VirtualFileSystem.cpp.
|
noexcept |
Trigger a standard filesystem audio alert.
Definition at line 433 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 438 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 444 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 452 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 458 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 473 of file VirtualFileSystem.cpp.
|
nodiscard |
Select a folder using a dialog.
| def_path | Default starting path to open dialog at. |
Definition at line 490 of file VirtualFileSystem.cpp.
|
privatedelete |
Copy assignment operator.
|
privatedelete |
Move assignment operator.