28 #define GET_PATH_TO_EXECUTABLE "/proc/self/exe" 35 using std::regex_replace;
37 const regex SearchPathSplitter::EXTRACT_PATHSPEC (
"[^:]+");
52 throw error::Fatal (
"unable to discover path of running executable");
54 buff.resize(chars_read);
67 static const regex PICK_ORIGIN_TOKEN (
"\\$?ORIGIN/?");
68 static const string expandedOriginDir
69 = fsys::path (
findExePath()).parent_path().string() +
"/";
71 return regex_replace(src, PICK_ORIGIN_TOKEN, expandedOriginDir);
81 fsys::path modulePathName (moduleName);
84 while (!fsys::exists (modulePathName))
87 if (searchLocation.isValid())
88 modulePathName = fsys::path() / searchLocation.next() / moduleName;
90 throw error::Config (
"Module \""+moduleName.string()+
"\" not found" 91 + (searchPath.empty()?
".":
" in search path: "+searchPath));
94 TRACE (config,
"found module %s", modulePathName.string().c_str());
95 return modulePathName.string();
Helpers to handle directory search paths.
string findExePath()
retrieve the location of the executable
const size_t STRING_MAX_RELEVANT
safety guard: maximum number of chars to process.
Implementation namespace for support and library code.
string replaceMagicLinkerTokens(string const &src)
replace $ORIGIN tokens in the given string
Derived specific exceptions within Lumiera's exception hierarchy.
Marker types to indicate a literal string and a Symbol.
#define GET_PATH_TO_EXECUTABLE
how to retrieve the absolute path of the currently running executable on a Linux system: read the lin...
Lumiera error handling (C++ interface).
Helper: Access a path Specification as a sequence of filesystem Paths.
string resolveModulePath(fsys::path moduleName, string searchPath)
helper to establish the location to search for loadable modules, configuration files, icons and further resources.