|
#include <ArmarXCore/core/system/ArmarXDataPath.h>
Static Public Member Functions | |
static void | addDataPath (const std::string &dataPath) |
static void | addDataPaths (const std::string &dataPathList) |
static void | addDataPaths (const std::vector< std::string > &dataPathList) |
static std::string | cleanPath (const std::string &filepathStr) |
static bool | FindPackageAndAddDataPath (const std::string &packageName) |
Search for the package and add its data path if it was found. More... | |
static std::string | getAbsolutePath (const std::string &relativeFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true) |
static bool | getAbsolutePath (const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true) |
static std::string | GetCachePath () |
The base Cache directory of ArmarX. More... | |
static std::vector< std::string > | getDataPaths () |
static std::string | GetDefaultUserConfigPath () |
The user config directory of ArmarX. More... | |
static std::string | getHomePath () |
static std::string | getProject (const std::vector< std::string > &projects, const std::string &relativeFilename) |
static std::string | getRelativeArmarXPath (const std::string &absolutePathString) |
This method tries to morph a given absolute path into a relative path to a ArmarXDataPath. More... | |
static void | initDataPaths (const std::string &dataPathList) |
static bool | mergePaths (std::string path, std::string subPath, std::string &result) |
static std::string | relativeTo (const std::string &from, const std::string &to) |
Transform an absolute filepath into a relative path of the other absolute filepath. More... | |
static bool | ReplaceEnvVars (std::string &string) |
ReplaceEnvVars replaces environment variables in a string with their values, if the env. More... | |
static void | ReplaceVar (std::string &string, const std::string varName, const std::string &varValue) |
Replaces all occurences of variables in bash notation, e.g. More... | |
static void | ResolveHomePath (std::string &path) |
Resolves a path like ~/myfile.txt or $HOME/myfile.txt to /home/user/myfile.txt. More... | |
static std::string | resolvePath (const std::string &path, bool verbose=true) |
Resolves environment variables and home paths and tries to make path absolute. More... | |
static bool | SearchReadableFile (const std::string &querryFileName, std::string &resultFileName, bool verbose=true) |
The ArmarXDataPath class provides static methods to handle ArmarX data directories.
Data paths can be defined via the environment variable ArmarXData_DIRS (semicolon separated list). Additionally ArmarX Properties (ArmarX.DataPath) can be used either by command line or by config files.
The search order is as follows
Usually, the paths are initialized by the framework automatically (see Application).
To convert a filename given relatively to one of the data directories use the following syntax
Definition at line 57 of file ArmarXDataPath.h.
|
static |
Definition at line 576 of file ArmarXDataPath.cpp.
|
static |
Add data paths to the internal search list. Multiple paths are separated by a semicolon ";" and environment variables specified with "${}" inside the paths are expanded. The latest additions have the highest precedence, when solving relative paths.
This would result in the following precedence order: home, var, root, usr.
dataPathList | A semicolon separated list of absolute paths. Each path is checked for existance and in case it is not present it is silently ignored. |
Definition at line 559 of file ArmarXDataPath.cpp.
|
static |
Definition at line 566 of file ArmarXDataPath.cpp.
|
static |
|
static |
Search for the package and add its data path if it was found.
Definition at line 829 of file ArmarXDataPath.cpp.
|
static |
This method searches all data paths for a valid file. The precedence of the datapaths is in the insertion order. The datapaths given to this function have the highest precedence.
relativeFilename | The file relatively to one of the data paths |
additionalSearchPaths | Additional search paths that are not in the globally registered variable. |
verbose | If set to true, the function will print all available paths and the requested file to the console on failure. |
Definition at line 208 of file ArmarXDataPath.cpp.
|
static |
This method searches all data paths for a valid file. The precedence of the datapaths is in the insertion order. The datapaths given to this function have the highest precedence.
relativeFilename | The file relatively to one of the data paths |
storeAbsoluteFilename | In case a valid absolute filename can be found, it is stored here. |
additionalSearchPaths | Additional search paths that are not in the globally registered variable. |
verbose | If set to true, the function will print all available paths and the requested file to the console on failure. |
Definition at line 111 of file ArmarXDataPath.cpp.
|
static |
The base Cache directory of ArmarX.
Definition at line 734 of file ArmarXDataPath.cpp.
|
static |
Returns all absolute data paths.
Definition at line 620 of file ArmarXDataPath.cpp.
|
static |
The user config directory of ArmarX.
Definition at line 782 of file ArmarXDataPath.cpp.
|
static |
The base directory of ArmarX. Checks the environment variables for ArmarXHome_DIR and returns the entry.
Definition at line 583 of file ArmarXDataPath.cpp.
|
static |
Search all project data paths and reports within which project the file can be located. First hit is reported. If none of the project's data paths contains the file, an empty string is returned.
projects | List of ArmarXProjects |
relativeFilename | Filename relative to a project's data directory. |
Definition at line 301 of file ArmarXDataPath.cpp.
|
static |
This method tries to morph a given absolute path into a relative path to a ArmarXDataPath.
absolutePathString | String of an absolute (file)path |
Definition at line 382 of file ArmarXDataPath.cpp.
|
static |
Initializes data paths. Automatically called by an Application.
Definition at line 477 of file ArmarXDataPath.cpp.
|
static |
Definition at line 456 of file ArmarXDataPath.cpp.
|
static |
Transform an absolute filepath into a relative path of the other absolute filepath.
For example:
from | Base path, to which the path should be made relative |
to | Path that should be made relative |
LocalException |
Definition at line 410 of file ArmarXDataPath.cpp.
|
static |
ReplaceEnvVars replaces environment variables in a string with their values, if the env.
variable is set. E.g. "${HOME}/.armarx/default.cfg"
string | String in which the environment variables are to be replaced |
Definition at line 483 of file ArmarXDataPath.cpp.
|
static |
Replaces all occurences of variables in bash notation, e.g.
${HOME}, with the given value in the string.
string | String to be modified |
varName | Name of the variable |
varValue | Value to be inserted in place of varName occurrences |
Definition at line 513 of file ArmarXDataPath.cpp.
|
static |
Resolves a path like ~/myfile.txt or $HOME/myfile.txt to /home/user/myfile.txt.
string |
Definition at line 521 of file ArmarXDataPath.cpp.
|
static |
Resolves environment variables and home paths and tries to make path absolute.
path | The path, may contain env. variables and be a relative data path. |
verbose | Passed to getAbsolutePath() . |
Definition at line 542 of file ArmarXDataPath.cpp.
|
static |
Definition at line 218 of file ArmarXDataPath.cpp.