Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::FileSystem Class Reference

Resolves asset paths and loads files into memory. More...

#include <FileSystem.h>

Public Member Functions

std::filesystem::path GetExecutableFolder () const
 Return the directory containing the running executable.
 
std::filesystem::path GetAssetsFolder () const
 Return the runtime assets directory.
 
std::vector< char > LoadFile (const std::filesystem::path &path)
 Load an arbitrary file into a byte buffer.
 
std::vector< char > LoadAssetFile (const std::string &relativePath)
 Load a file from the assets directory into a byte buffer.
 
std::string LoadAssetFileText (const std::string &relativePath)
 Load a text file from the assets directory into a string.
 

Detailed Description

Resolves asset paths and loads files into memory.

Owned by the Engine singleton. All relative paths passed to Load* methods are resolved against GetAssetsFolder().

Definition at line 27 of file FileSystem.h.

Member Function Documentation

◆ GetAssetsFolder()

std::filesystem::path mnd::FileSystem::GetAssetsFolder ( ) const

Return the runtime assets directory.

Resolved as ASSETS_DIR relative to the executable folder. CMake copies the source-tree assets/ folder here post-build.

Returns
Absolute path to the assets directory.

Definition at line 41 of file FileSystem.cpp.

References GetExecutableFolder(), and kAssetsDirName.

Referenced by mnd::ModelImporter::Import(), mnd::Texture::Load(), LoadAssetFile(), and mnd::GameObject::LoadGLTF().

◆ GetExecutableFolder()

std::filesystem::path mnd::FileSystem::GetExecutableFolder ( ) const

Return the directory containing the running executable.

Returns
Absolute path to the executable's parent directory.

Definition at line 22 of file FileSystem.cpp.

Referenced by GetAssetsFolder().

◆ LoadAssetFile()

std::vector< char > mnd::FileSystem::LoadAssetFile ( const std::string &  relativePath)

Load a file from the assets directory into a byte buffer.

Parameters
relativePathPath relative to GetAssetsFolder().
Returns
File contents as a vector of bytes.

Definition at line 73 of file FileSystem.cpp.

References GetAssetsFolder(), and LoadFile().

Referenced by mnd::Audio::Load(), and LoadAssetFileText().

◆ LoadAssetFileText()

std::string mnd::FileSystem::LoadAssetFileText ( const std::string &  relativePath)

Load a text file from the assets directory into a string.

Parameters
relativePathPath relative to GetAssetsFolder().
Returns
File contents as a UTF-8 string.

Definition at line 78 of file FileSystem.cpp.

References LoadAssetFile().

Referenced by mnd::PostProcess::Init(), mnd::ParticleSystem::Init(), mnd::Material::Load(), mnd::Scene::Load(), and mnd::GameObject::LoadGLTF().

◆ LoadFile()

std::vector< char > mnd::FileSystem::LoadFile ( const std::filesystem::path &  path)

Load an arbitrary file into a byte buffer.

Parameters
pathAbsolute or relative path to the file.
Returns
File contents as a vector of bytes.

Definition at line 52 of file FileSystem.cpp.

References LOG_ERROR.

Referenced by LoadAssetFile().


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