Added directory location code for Linux

This commit is contained in:
Matt Hill
2014-08-19 22:20:59 -04:00
parent 1390eaeecd
commit b9a8b87cf1

View File

@@ -26,6 +26,20 @@ std::string getExeDir()
} }
return directory; return directory;
#else #else
return ""; char buffer[2048];
readlink("/proc/self/exe", buffer, 2048);
std::stringstream ss;
ss << buffer;
std::string exeFile = ss.str();
std::string directory;
const size_t last_slash_idx = exeFile.rfind('/');
if (std::string::npos != last_slash_idx)
{
directory = exeFile.substr(0, last_slash_idx);
}
return directory;
#endif #endif
} }