Manager helping with path finding and resource loading. More...
Manager helping with path finding and resource loading.
An important role if this component is to allow to setup data path in one location, for the whole engine. In other words, the components working with resource path will use this manager to reconstruct all the paths they would need. For this, they will need paths relative to the working directory, unless specified otherwise.
Typical usage would be :
Globally, it uses 3 keywords for all paths it manipulates :
Transformations from one path to another use these keywords :
void nkResources::ResourceManager::setWorkingPath | ( | nkMemory::StringView | path | ) |
Sets the working path.
path | The path of the wanted path, relative to the path from where the software is launched. |
void nkResources::ResourceManager::setWorkingPathAbsolute | ( | nkMemory::StringView | path | ) |
Sets the working path.
path | The path of the wanted path, absolute. |
nkMemory::StringView nkResources::ResourceManager::getWorkingPath | ( | ) | const |
nkMemory::StringView nkResources::ResourceManager::getWorkingPathAbsolute | ( | ) | const |
nkMemory::StringView nkResources::ResourceManager::getLaunchedPath | ( | ) | const |
void nkResources::ResourceManager::setLaunchedPath | ( | nkMemory::StringView | path | ) |
Allows to override the path from which the program is launched.
nkMemory::String nkResources::ResourceManager::getRelativeFromAbsolute | ( | nkMemory::StringView | absolutePath | ) | const |
Converts a path, from absolute, to a path relative to the launched path.
absolutePath | The absolute path to convert. |
nkMemory::String nkResources::ResourceManager::getAbsoluteFromRelative | ( | nkMemory::StringView | relativePath | ) | const |
Converts a path, from relative to the launched directory, to absolute.
relativePath | The relative path to convert. |
nkMemory::String nkResources::ResourceManager::getRelativeFromWorkingDir | ( | nkMemory::StringView | workingPath | ) | const |
Converts a path, from relative to the working directory, to relative to the launched path.
workingPath | The path relative to the working directoy to convert. |
nkMemory::String nkResources::ResourceManager::getAbsoluteFromWorkingDir | ( | nkMemory::StringView | workingPath | ) | const |
Converts a path, from relative to the working directory, to absolute.
workingPath | The path relative to the working directoy to convert. |
nkMemory::String nkResources::ResourceManager::getFromWorkingDirFromRelative | ( | nkMemory::StringView | relativePath | ) | const |
Converts a path, from relative to the launched directory, to relative to the working directory.
relativePath | The path relative to the launched path to convert. |
nkMemory::String nkResources::ResourceManager::getFromWorkingDirFromAbsolute | ( | nkMemory::StringView | absolutePath | ) | const |
Converts a path, from absolute, to relative to the working directory.
absolutePath | The absolute path to convert. |
bool nkResources::ResourceManager::checkFileExists | ( | nkMemory::StringView | filePathAbs | ) | const |
Checks if a file exists for a certain path.
filePathAbs | The absolute path to check. |
void nkResources::ResourceManager::checkFolderExists | ( | nkMemory::StringView | path | ) |
Checks if a folder exists for a certain path.
path | The absolute path to check. |
nkMemory::Buffer nkResources::ResourceManager::loadFileIntoMemory | ( | nkMemory::StringView | filePathAbs, |
bool | silent = false |
||
) |
Loads a file into memory.
filePathAbs | The path to the file, absolute. |
silent | If a failure in finding the requested file should not be logged. True for no logging, false otherwise. |
bool nkResources::ResourceManager::saveFileToDisk | ( | nkMemory::StringView | outPathAbs, |
nkMemory::BufferView<> | data, | ||
bool | silent = false |
||
) |
Saves a file to the disk, writing the binary buffer provided as a parameter.
outPathAbs | The absolute path to save the file to. |
data | The binary data to save. |
silent | If a failure in finding the requested file should not be logged. True for no logging, false otherwise. |