diff --git a/src/common/pathTools.cpp b/src/common/pathTools.cpp index f1ca7d22..57ce464e 100644 --- a/src/common/pathTools.cpp +++ b/src/common/pathTools.cpp @@ -125,3 +125,14 @@ bool copyFile(const string &sourcePath, const string &destPath) { return true; } + +string getExecutablePath() { + char binRootPath[PATH_MAX]; + +#ifdef _WIN32 +#else + readlink("/proc/self/exe", binRootPath, PATH_MAX); +#endif + + return std::string(binRootPath); +} diff --git a/src/common/pathTools.h b/src/common/pathTools.h index 55fa3f58..3ad73e4e 100644 --- a/src/common/pathTools.h +++ b/src/common/pathTools.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -46,5 +47,6 @@ bool fileExists(const string &path); bool makeDirectory(const string &path); bool copyFile(const string &sourcePath, const string &destPath); string getLastPathElement(const string &path); +string getExecutablePath(); #endif