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 #else
#include <wait.h> #include <wait.h>
#endif #endif
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
#include <errno.h> #include <errno.h>
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
@ -401,12 +404,18 @@ void Util::Config::addBasicConnectorOptions(JSON::Value & capabilities){
/// Gets directory the current executable is stored in. /// Gets directory the current executable is stored in.
std::string Util::getMyPath(){ std::string Util::getMyPath(){
char mypath[500]; 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); int ret = readlink("/proc/self/exe", mypath, 500);
if (ret != -1){ if (ret != -1){
mypath[ret] = 0; mypath[ret] = 0;
}else{ }else{
mypath[0] = 0; mypath[0] = 0;
} }
#endif
std::string tPath = mypath; std::string tPath = mypath;
size_t slash = tPath.rfind('/'); size_t slash = tPath.rfind('/');
if (slash == std::string::npos){ if (slash == std::string::npos){