ALT: Get backends dir relative from executable name
To be runnable without `/proc` mounted. So this is not really `get_executable_path` anymore but more like `get_executables_path` now. Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
parent
6c883bac1f
commit
8745edc204
1 changed files with 6 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <cctype>
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
|
|
@ -418,6 +419,11 @@ static fs::path get_executable_path() {
|
|||
base_path = base_path.substr(0, last_slash);
|
||||
}
|
||||
return base_path + "/";
|
||||
#elif defined(__gnu_linux__)
|
||||
std::string executable_path(reinterpret_cast<const char *>(getauxval(AT_EXECFN)));
|
||||
fs::path bindir = fs::path(executable_path.data()).parent_path();
|
||||
fs::path libdir = bindir.parent_path() / "lib" / "llama";
|
||||
return fs::is_directory(libdir) ? libdir : bindir;
|
||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
||||
std::string base_path = ".";
|
||||
std::vector<char> path(1024);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue