fix(util/lean_path): get_exe_location for Windows

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-22 19:09:33 -08:00
parent cc9e16c3fc
commit 50de85ee29

View file

@ -21,7 +21,17 @@ static std::string get_exe_location() {
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
return std::string(path);
std::wstring pathstr(path);
std::string r(pathstr.begin(), pathstr.end());
while (true) {
if (r.empty())
throw exception("failed to locate Lean executable location");
if (r.back() == g_sep) {
r.pop_back();
return r;
}
r.pop_back();
}
}
#elif defined(__APPLE__)
// OSX version