|
CARMA C++
|
This class is a collection of static methods to return specific directories for a standard carma tree. More...
#include <carma/util/RuntimeDirs.h>
Static Public Member Functions | |
| static std::string | getConfDir (const std::string &programName) |
| Get the configuration directory - assumes standard carma tree. More... | |
| static std::string | getConfFile (const std::string &programName, const std::string &confFilename) |
| Get the absolute path of a configuration file. More... | |
| static std::string | getExecutable (const std::string &programName) |
| Get absolute full path of executable, including program executable. More... | |
| static std::string | getExecutableDir (const std::string &programName) |
| Get the directory where this program executable lives. More... | |
| static std::string | getRootDir (const std::string &programName) |
| Get the root build or install directory - assumes standard carma tree. More... | |
This class is a collection of static methods to return specific directories for a standard carma tree.
The standard carma tree is assumed to be of the form
carmaRoot
|
---------------------------
/ | | \
bin lib carma conf
|
-------------
/ | \
Xpgk Ypkg Zpkg
| | |
Test Test Test
These routines start by getting the full path of the executable using the "which" shell command for the program name (usually passed in as arg[0] to the program) . We assume that the these are carma programs and are run from one of two locations:
If the program has been run from a "bin" directory, then its parent is selected as carmaRoot, otherwise the tree is ascended until "carma" is found and then its parent is selected as carmaRoot. If neither of these directories is found then an exception is thrown. All filenames are canonicalized, removing symbolic links and redundant slashes.
Definition at line 59 of file RuntimeDirs.h.
|
static |
Get the configuration directory - assumes standard carma tree.
The conf directory is assumed to be /carmaRoot/conf/. This string is an absolute path that ends with a slash character (/).
| programName | as invoked (e.g. arg0) |
| ErrorException | if getRootDir() or canonicalize() has problems |
|
static |
Get the absolute path of a configuration file.
If the filename begins with a slash then it is assumed to be an absolute path and is left untouched. If the filename begins with a dash then it is assumed to be a path local to the current working directory and the dash is removed with no further processing. All other filenames are appended to the conf directory and the conf directory canonicalized if requested.
| programName | as invoked (e.g. arg0) |
| confFilename |
| ErrorException | if getRootDir() or canonicalize() has problems |
|
static |
Get absolute full path of executable, including program executable.
The bash builtin "which" command is used to obtain this path.
| programName | as invoked (e.g. arg0) |
| ErrorException | under numerous conditions associated with fork/exec of the bash which command |
|
static |
Get the directory where this program executable lives.
This string is an absolute path that ends with a slash character (/).
| programName | as invoked (e.g. arg0) |
| ErrorException | if get Excecutable or canonicalize() has problems |
|
static |
Get the root build or install directory - assumes standard carma tree.
This string is an absolute path that ends with a slash character (/).
| programName | as invoked (e.g. arg0) |
| ErrorException | if the directory from which the program was run has no parent, or is not part of a standard carma tree, or if cannot get filename of executable |