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
VirtualFileSystem.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_FS_VIRTUALFILESYSTEM_HPP_
9#define GALAXY_FS_VIRTUALFILESYSTEM_HPP_
10
11#include <span>
12#include <string>
13#include <vector>
14
15#include <Raylib.hpp>
16
20
21namespace galaxy
22{
27 {
28 public:
32 VirtualFileSystem() noexcept;
33
37 ~VirtualFileSystem() noexcept;
38
46 [[nodiscard]]
47 std::string read(const std::string& file);
48
56 [[nodiscard]]
57 std::vector<std::uint8_t> read_binary(const std::string& file);
58
69 [[nodiscard]]
70 bool write(const std::string& data, const std::string& file);
71
82 [[nodiscard]]
83 bool write_binary(std::span<std::uint8_t> data, const std::string& file);
84
94 [[nodiscard]]
95 bool write_raw(const void* data, const std::size_t size, const std::string& file);
96
104 [[nodiscard]]
105 std::optional<ray::Image> load_ray_image(const std::string& filename) noexcept;
106
115 [[nodiscard]]
116 std::optional<ray::Image> load_ray_image_anim(const std::string& filename, int* frames) noexcept;
117
125 [[nodiscard]]
126 std::optional<ray::Texture2D> load_ray_texture(const std::string& filename) noexcept;
127
135 [[nodiscard]]
136 std::optional<ray::Wave> load_ray_wave(const std::string& filename) noexcept;
137
145 [[nodiscard]]
146 std::optional<ray::Music> load_ray_music_stream(const std::string& filename) noexcept;
147
157 [[nodiscard]]
158 std::optional<ray::Font> load_ray_font(const std::string& filename, int font_size, std::span<int> font_chars) noexcept;
159
167 void mkdir(const std::string& dir) noexcept;
168
176 void remove(const std::string& path) noexcept;
177
185 [[nodiscard]]
186 bool exists(const std::string& file) noexcept;
187
195 [[nodiscard]]
196 bool is_dir(const std::string& path) noexcept;
197
205 [[nodiscard]]
206 std::vector<std::string> list(const std::string& dir);
207
211 void alert() noexcept;
212
220 void notification(const std::string& title, const std::string& msg, const DialogIcon icon) noexcept;
221
233 [[nodiscard]]
234 int message_box(const std::string& title, const std::string& msg, const DialogType type, const DialogIcon icon, const DialogButton btn) noexcept;
235
246 [[nodiscard]]
247 std::string input_box(const std::string& title, const std::string& msg, const std::string& default_text = "", const bool password = false) noexcept;
248
257 [[nodiscard]]
258 std::string open_save_dialog(const std::string& default_filename, const std::vector<const char*>& filters = {});
259
268 [[nodiscard]]
269 std::string open_file_dialog(const std::vector<const char*>& filters = {}, const std::string& def_path = "");
270
278 [[nodiscard]]
279 std::string select_folder_dialog(const std::string& def_path = "");
280
281 private:
286
291
296
301 };
302} // namespace galaxy
303
304#endif
void alert() noexcept
Trigger a standard filesystem audio alert.
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.
VirtualFileSystem(const VirtualFileSystem &)=delete
Copy constructor.
~VirtualFileSystem() noexcept
Destructor.
bool is_dir(const std::string &path) noexcept
Checks if a file is a folder.
bool write_binary(std::span< std::uint8_t > data, const std::string &file)
Writes a binary file to disk.
std::vector< std::string > list(const std::string &dir)
Get assets in an asset folder.
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::string read(const std::string &file)
Read a file.
std::optional< ray::Wave > load_ray_wave(const std::string &filename) noexcept
Load wave data from VFS. You must manually free the data after.
VirtualFileSystem & operator=(const VirtualFileSystem &)=delete
Copy assignment operator.
std::optional< ray::Texture2D > load_ray_texture(const std::string &filename) noexcept
Load a texture from VFS. You must manually free the data after.
bool write_raw(const void *data, const std::size_t size, const std::string &file)
Raw data writing.
bool write(const std::string &data, const std::string &file)
Writes a file to disk.
void notification(const std::string &title, const std::string &msg, const DialogIcon icon) noexcept
Trigger a system notification.
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.
bool exists(const std::string &file) noexcept
Does the file exist in the vfs.
std::string open_file_dialog(const std::vector< const char * > &filters={}, const std::string &def_path="")
Open a file dialog.
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::Music > load_ray_music_stream(const std::string &filename) noexcept
Load module music from VFS. You must manually free the data after.
std::string open_save_dialog(const std::string &default_filename, const std::vector< const char * > &filters={})
Open a save file dialog.
std::string select_folder_dialog(const std::string &def_path="")
Select a folder using a dialog.
VirtualFileSystem(VirtualFileSystem &&)=delete
Move constructor.
VirtualFileSystem & operator=(VirtualFileSystem &&)=delete
Move assignment operator.
void remove(const std::string &path) noexcept
Delete a file or folder.
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.
VirtualFileSystem() noexcept
Constructor.
std::vector< std::uint8_t > read_binary(const std::string &file)
Read a binary file.
void mkdir(const std::string &dir) noexcept
Creates an empty folder in the filesystem relative to the root.
Application.hpp galaxy.
DialogButton
Type of button for tinyfd boxes.
DialogType
Type of dialog box for use with tinyfd.
DialogIcon
Type of native system icon to display on file dialogs.