Correctly detect the executable path if we use a AppImage. (#272)

Correctly detect the executable path if we use a AppImage.
This commit is contained in:
Matthieu Gautier 2019-09-09 18:37:37 +02:00 committed by GitHub
commit 351e573bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -283,6 +283,21 @@ std::string getExecutablePath()
{ {
char binRootPath[PATH_MAX]; char binRootPath[PATH_MAX];
char* cAppImage = ::getenv("APPIMAGE");
if (cAppImage) {
char* cArgv0 = ::getenv("ARGV0");
char* cOwd = ::getenv("OWD");
if (!cArgv0 && !cOwd) {
// Nothing to clean, goto in the same function...
// This is silly but .. ok..
// And we should pass here, if APPIMAGE is set ARGV0 and OWD should also
// (except if there is a bug in appimage)
goto normal;
}
return appendToDirectory(cOwd, cArgv0);
}
normal:
#ifdef _WIN32 #ifdef _WIN32
GetModuleFileName(NULL, binRootPath, PATH_MAX); GetModuleFileName(NULL, binRootPath, PATH_MAX);
return std::string(binRootPath); return std::string(binRootPath);