[ABI Break] Correctly detect the executable path in appimage.

There are two executable path :
- The user one (the appimage path)
- The real one (in the appimage archive)

When we search of `library.xml` we need the user one.
But when we search of `aria2c` or `kiwix-serve` we need the real one.

Fix kiwix/kiwix-desktop#256
This commit is contained in:
Matthieu Gautier committed 2019-09-17 11:23:16 +02:00
1 parent 15d5b4ed58
commit 9b4419f3fc
4 files changed
+12 -16

No files matched your search

+9 -13
View File
@@ -279,24 +279,20 @@ bool copyFile(const std::string& sourcePath, const std::string& destPath)
return true;
}
std::string getExecutablePath()
std::string getExecutablePath(bool realPathOnly)
{
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;
if (!realPathOnly) {
char* cAppImage = ::getenv("APPIMAGE");
if (cAppImage) {
char* cArgv0 = ::getenv("ARGV0");
char* cOwd = ::getenv("OWD");
if (cArgv0 && cOwd) {
return appendToDirectory(cOwd, cArgv0);
}
}
return appendToDirectory(cOwd, cArgv0);
}
normal:
#ifdef _WIN32
GetModuleFileName(NULL, binRootPath, PATH_MAX);