gramods
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
gramods::gmCore::FileResolver Class Reference

The FileResolver provides a means to locate resources in a portable manner. More...

#include <FileResolver.hh>

Classes

struct  Impl
 

Public Types

enum class  Check { None , ReadableFile , WritableFile }
 Flag for checking path after resolving pattern. More...
 

Public Member Functions

bool readUrnFile (std::filesystem::path urn_file)
 Reads in mappings from the specified URN file. More...
 
std::filesystem::path resolve (std::string, Check check=Check::None)
 Resolves the specified string as a path using the currently loaded rules. More...
 
std::filesystem::path resolve (std::filesystem::path path, Check check=Check::None)
 Resolves the specified path using the currently loaded rules. More...
 

Static Public Member Functions

static std::filesystem::path getPathToExecutable ()
 Returns the path to the running executable. More...
 
static FileResolvergetDefault ()
 Returns the default resolver. More...
 

Detailed Description

The FileResolver provides a means to locate resources in a portable manner.

The default behavior (FileResolver::getDefault()) is to first check if there is an environment variable GM_URN_FILE pointing at a file. If not it checks if there is an environment variable GM_HOME that points at a folder with a file "gramods.urn". If not it checks if there is a file gramods.urn in the same folder as the executable currently running.

The URN file is parsed for mappings in the form urn:key: path/. If the path is absolute, then the occurance of "urn:key:" is replaced with this path and if it is relative, the key is replaced with a path relative the location of the URN file.

Member Enumeration Documentation

◆ Check

Flag for checking path after resolving pattern.

Member Function Documentation

◆ getDefault()

static FileResolver* gramods::gmCore::FileResolver::getDefault ( )
inlinestatic

Returns the default resolver.

◆ getPathToExecutable()

std::filesystem::path gramods::gmCore::FileResolver::getPathToExecutable ( )
static

Returns the path to the running executable.

◆ readUrnFile()

bool gramods::gmCore::FileResolver::readUrnFile ( std::filesystem::path  urn_file)

Reads in mappings from the specified URN file.

◆ resolve() [1/2]

std::filesystem::path gramods::gmCore::FileResolver::resolve ( std::filesystem::path  path,
Check  check = Check::None 
)
inline

Resolves the specified path using the currently loaded rules.

◆ resolve() [2/2]

std::filesystem::path gramods::gmCore::FileResolver::resolve ( std::string  str_path,
Check  check = Check::None 
)

Resolves the specified string as a path using the currently loaded rules.


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