106 [[nodiscard]]
bool is_open()
const;
119 static bool file_exists(
const std::string& file_path);
137 [[nodiscard]] std::string
get_path()
const;
151 bool store_bytes(
const std::vector<char>& content);
157 void seek(
int length);
175 SDL_IOStream* _file =
nullptr;
176 std::string _file_path;
178 bool resolve_path(
const std::string& file_path,
ModeFlags mode_flags);
A RAII wrapper for SDL3 file operations supporting read/write access.
Definition: file_system.h:72
void seek(int length)
Move the file pointer to the given offset from the beginning.
Definition: file_system.cpp:253
~FileAccess()
Destructor automatically closes the file if it is open.
Definition: file_system.cpp:201
FileAccess()=default
Default constructor (empty, file not opened)
std::string get_path() const
Get the path relative to the base (removes res:// or user:// prefix)
Definition: file_system.cpp:265
std::vector< char > get_file_as_bytes()
Read the entire file as a vector of bytes.
Definition: file_system.cpp:209
void seek_end(int position)
Move the file pointer relative to the end of the file.
Definition: file_system.cpp:257
bool store_string(const std::string &content="")
Write a string to the file.
Definition: file_system.cpp:274
bool store_bytes(const std::vector< char > &content)
Write a byte array to the file.
Definition: file_system.cpp:289
FileAccess & operator=(const FileAccess &)=delete
bool open(const std::string &file_path, ModeFlags mode_flags=ModeFlags::READ)
Open a file for reading/writing.
Definition: file_system.cpp:181
FileAccess(const FileAccess &)=delete
std::string get_file_as_str()
Read the entire file as a String.
Definition: file_system.cpp:226
static bool file_exists(const std::string &file_path)
Check if a file exists at the given path.
Definition: file_system.cpp:231
bool is_open() const
Check if the file is currently open.
Definition: file_system.cpp:205
std::string get_absolute_path() const
Get the absolute resolved path to the file.
Definition: file_system.cpp:261
void close()
Close the file if it is open.
Definition: file_system.cpp:305
std::string load_assets_file(const std::string &file_path)
Loads a given file from res folder.
Definition: file_system.cpp:4
ModeFlags
Flags to indicate access modes.
Definition: file_system.h:59
@ READ_WRITE
Read then Write access.
@ WRITE
Write-only access.
@ WRITE_READ
Write then Read access.
ma_result _ember_init_vfs(Ember_VFS *vfs)
Definition: file_system.cpp:118
std::vector< char > load_file_into_memory(const std::string &file_path)
Loads a given file from res folder into memory.
Definition: file_system.cpp:12
Ember file (SDL_stream)
Definition: file_system.h:33
SDL_IOStream * stream
Definition: file_system.h:34
Engine virtual file system.
Definition: file_system.h:43
ma_vfs_callbacks base
Definition: file_system.h:44