From de733c31a313ee1812cd067f53c814f0fcf9f04b Mon Sep 17 00:00:00 2001 From: Oswald Auguste de Bruin <oswald.de.bruin@ddvtech.com> Date: Wed, 4 Sep 2013 15:55:35 +0200 Subject: [PATCH] Fix in lib which makes mistserver compilable and usable for mac --- lib/config.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/config.cpp b/lib/config.cpp index b5156308..e856eb83 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -10,6 +10,9 @@ #else #include <wait.h> #endif +#if defined(__APPLE__) +#include <mach-o/dyld.h> +#endif #include <errno.h> #include <iostream> #include <signal.h> @@ -401,12 +404,18 @@ void Util::Config::addBasicConnectorOptions(JSON::Value & capabilities){ /// Gets directory the current executable is stored in. std::string Util::getMyPath(){ char mypath[500]; +#ifdef __APPLE__ + memset( mypath, 0, 500); + unsigned int refSize = 500; + int ret = _NSGetExecutablePath(mypath,&refSize); +#else int ret = readlink("/proc/self/exe", mypath, 500); if (ret != -1){ mypath[ret] = 0; }else{ mypath[0] = 0; } +#endif std::string tPath = mypath; size_t slash = tPath.rfind('/'); if (slash == std::string::npos){