29#define GET_PATH_TO_EXECUTABLE "/proc/self/exe"
37 using std::regex_replace;
49 if (not fs::exists (selfExe))
50 throw error::Fatal (
"unable to discover path of running executable");
51 return fs::canonical (selfExe);
62 static const regex PICK_ORIGIN_TOKEN{
"\\$?ORIGIN/?", regex::optimize};
63 static const string expandedOriginDir
64 =
findExePath().parent_path().generic_string() +
"/";
66 return regex_replace (src, PICK_ORIGIN_TOKEN, expandedOriginDir);
76 fs::path modulePathName (moduleName);
79 while (not fs::exists (modulePathName))
82 if (not searchLocation)
85 %(searchPath.empty()?
".":
" in search path: "+searchPath)};
86 modulePathName = *searchLocation / moduleName;
90 TRACE (config,
"found module %s",
cStr(modulePathName.generic_string()));
91 return modulePathName.generic_string();
Helper: Access a path Specification as a sequence of filesystem Paths.
static const regex ACCEPT_PATHELEMENT
A front-end for using printf-style formatting.
Lumiera error handling (C++ interface).
Implementation namespace for support and library code.
string resolveModulePath(fs::path moduleName, string searchPath)
helper to establish the location to search for loadable modules, configuration files,...
fs::path findExePath()
retrieve the location of the executable
string replaceMagicLinkerTokens(string const &src)
replace $ORIGIN tokens in the given string
LumieraError< LERR_(FATAL), Logic > Fatal
LumieraError< LERR_(CONFIG), Invalid > Config
#define GET_PATH_TO_EXECUTABLE
how to retrieve the absolute path of the currently running executable on a Linux system: read the lin...
Helpers to handle directory search paths.
Marker types to indicate a literal string and a Symbol.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.