Function Karana::Core::findResource

Function Karana::Core::findResource#

Function Documentation#

std::filesystem::path Karana::Core::findResource(const std::filesystem::path &path)#

Find the given resource file on the global ResourceFinder.

This is equivalent to calling

ResourceFinder::singleton().resolve(path)

If the given path is absolute, it is used verbatim without any searching as long as the path exists.

If the path is relative, this function checks relative to a configured list of search paths, returning the absolute path of the first existing file that is found.

The search paths are a list of filepaths in descending order of priority:

First, the current directory is considered.

Next, a list determined by the KARANA_RESOURCE_PATH environment variable, which should be a list of filepaths, separated by operating system’s standard delimiter (‘:’ on macos or linux, ‘;’ on windows). The search paths may further be modified at runtime using the methods of ResourceFinder::singleton.

Finally, the ‘share’ directory for miscellaneous installed Karana files as given by Karana::Core::findShareDir.

If no exiting file can be found, an error will be thrown.

Parameters:

path – The filepath to search for.

Returns:

The resolved, existing absolute path.