Added windows function to find relative dir of exe for conf and runtime

data
This commit is contained in:
Matt Hill
2014-08-19 22:14:32 -04:00
parent c6cc360d5a
commit 1390eaeecd
5 changed files with 42 additions and 0 deletions

View File

@@ -7,4 +7,25 @@ void sleep_ms(int sleepMs)
#else
usleep(sleepMs * 1000); // usleep takes sleep time in us (1 millionth of a second)
#endif
}
std::string getExeDir()
{
#ifdef WINDOWS
TCHAR szEXEPath[2048];
std::stringstream ss;
GetModuleFileName(NULL, szEXEPath, 2048);
ss << szEXEPath;
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;
#else
return "";
#endif
}