fix(util/lean_path): get_exe_location for Windows
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
cc9e16c3fc
commit
50de85ee29
1 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue