From 4b545b8ae2f0dc2cb341baa7d16e00d8276a1757 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 12 Dec 2011 14:49:49 +0000 Subject: [PATCH] --- src/common/pathTools.cpp | 11 +++++++++++ src/common/pathTools.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/common/pathTools.cpp b/src/common/pathTools.cpp index f1ca7d222..57ce464ef 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 55fa3f58b..3ad73e4e6 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