Fix in lib which makes mistserver compilable and usable for mac

This commit is contained in:
Oswald Auguste de Bruin 2013-09-04 15:55:35 +02:00
parent c373136679
commit de733c31a3

View file

@ -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){