![]() |
Lysa
0.0
Lysa 3D Engine
|
Virtual file system helper used to resolve portable paths.
Public Member Functions | |
| VirtualFS (const VirtualFSConfiguration &config, const std::shared_ptr< vireo::Vireo > &vireo) | |
| template<typename T > | |
| void | setResourcesPack (const std::filesystem::path &filePath) const |
| bool | fileExists (const std::string &uri) const |
| void | forEachDirectoryEntry (const std::string &uri, const std::function< void (DirectoryEntryType, const std::string &)> &callback, bool recursive=false) const |
| bool | directoryExists (const std::string &uri) const |
| std::pair< std::shared_ptr< std::streambuf >, std::shared_ptr< std::istream > > | openReadStream (const std::string &uri) const |
| std::ofstream | openWriteStream (const std::string &uri) const |
| void | loadBinaryData (const std::string &uri, std::vector< char > &out) const |
| std::string | loadString (const std::string &uri) const |
| std::byte * | loadImage (const std::string &uri, uint32 &width, uint32 &height, uint64 &size) const |
| void | loadLuaScript (const std::string &scriptName, std::vector< char > &out) const |
| void | loadShader (const std::string &shaderName, std::vector< char > &out) const |
| std::string | getPath (const std::string &uri) const |
| constexpr const std::string & | getLuaScriptsDirectory () const |
| constexpr std::string | getLuaScriptsURI () const |
| constexpr std::string | getLuaScriptURI (const std::string &scriptName) const |
| constexpr auto | useResourcesPack () const |
Static Public Member Functions | |
| static std::string | parentPath (const std::string &uri) |
| static void | destroyImage (std::byte *image) |
| static std::string | stripAppURI (const std::string &uri) |
| static std::string | stripUserURI (const std::string &uri) |
| static std::string | getCurrentDirectory () |
Static Public Attributes | |
| static constexpr auto | APP_URI {"app://"} |
| static constexpr auto | USER_URI {"user://"} |
| VirtualFS | ( | const VirtualFSConfiguration & | config, |
| const std::shared_ptr< vireo::Vireo > & | vireo | ||
| ) |
|
static |
Frees an image buffer allocated by loadImage().
| image | Pointer previously returned by loadImage() |
| bool directoryExists | ( | const std::string & | uri | ) | const |
Tests whether a directory exists at the given path or URI.
| uri | URI. |
| bool fileExists | ( | const std::string & | uri | ) | const |
Tests whether a regular file exists at the given path or URI.
| uri | URI. |
| void forEachDirectoryEntry | ( | const std::string & | uri, |
| const std::function< void (DirectoryEntryType, const std::string &)> & | callback, | ||
| bool | recursive = false |
||
| ) | const |
Iterates over the entries of a directory, transparent pack/filesystem.
| uri | Directory URI. |
| callback | Called for each entry with its type and its path relative to uri (a plain file name for the first level). |
| recursive | If true, also traverses the sub-directories. |
|
static |
|
inlineconstexpr |
Returns the configured Lua script directory
|
inlineconstexpr |
Returns the configured Lua script URI
|
inlineconstexpr |
Builds a Lua script URI from a script name
| std::string getPath | ( | const std::string & | uri | ) | const |
Resolves a path or app:// URI to a concrete OS path.
Implementations may expand environment variables, normalize separators, and map app:// to the application data/assets directory.
| void loadBinaryData | ( | const std::string & | uri, |
| std::vector< char > & | out | ||
| ) | const |
Loads the entire file contents into a byte buffer.
| uri | URI. |
| out | Destination buffer; its contents are replaced by the file bytes. |
| std::byte* loadImage | ( | const std::string & | uri, |
| uint32 & | width, | ||
| uint32 & | height, | ||
| uint64 & | size | ||
| ) | const |
Loads an image and returns an allocated RGBA (8‑bit per channel) buffer.
The caller owns the returned memory and must release it with destroyImage().
| uri | URI. |
| width | Output image width in pixels. |
| height | Output image height in pixels. |
| size | Output total buffer size in bytes (width*height*4). |
| void loadLuaScript | ( | const std::string & | scriptName, |
| std::vector< char > & | out | ||
| ) | const |
Loads a Lua script from the configured script directory
| scriptName | Script name without extension, relative to the script directory |
| out | Output buffer, its contents are replaced by the file bytes. |
| void loadShader | ( | const std::string & | shaderName, |
| std::vector< char > & | out | ||
| ) | const |
Loads a SPIR-V or DXIL shader from the configured shader directory
| shaderName | Shader name without extension and without path |
| out | Output buffer, its contents are replaced by the file bytes. |
| std::string loadString | ( | const std::string & | uri | ) | const |
| std::pair<std::shared_ptr<std::streambuf>, std::shared_ptr<std::istream> > openReadStream | ( | const std::string & | uri | ) | const |
Opens an input stream for reading a file, transparent pack/filesystem.
When a pack is active, returns a stream backed by a PackStreambuf (zero intermediate copy). When no pack is loaded, wraps the ifstream. Callers own the returned objects and must keep them alive together.
| uri | app:// URI. |
| std::ofstream openWriteStream | ( | const std::string & | uri | ) | const |
Opens an output stream for writing the file at URI.
The returned stream is typically opened in binary mode and may create intermediate directories depending on platform support. Callers should check stream.is_open() (or its state) to ensure the file was successfully opened.
| uri | URI. |
|
static |
Returns the parent directory of the provided path or URI.
For app:// URIs, the parent is computed after resolution. Trailing separators are ignored.
| uri | URI. |
|
inline |
|
static |
Removes the app:// prefix from an URI
|
static |
Removes the user:// prefix from an URI
|
inlineconstexpr |
Returns true if the virtual FS use a binary resource pack instead of files
|
staticconstexpr |
URI scheme used to reference files relative to the application root.
|
staticconstexpr |
URI scheme used to reference files in the platform-specific user data directory. Windows : %APPDATA%%\Lysa\userdata\[userDirectory] Linux : ~/.local/share/lysa/userdata/[userDirectory]