Skip to content

Commit

Permalink
OrcLib: SystemDetails: use fs::path with GetCurrentWorkingDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
jgautier-anssi authored and fabienfl-orc committed Nov 9, 2020
1 parent 769d7b2 commit 60cb64d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/OrcLib/SystemDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ HRESULT SystemDetails::LoadSystemDetails()
return S_OK;
}

HRESULT SystemDetails::GetCurrentWorkingDirectory(std::wstring& strCWD)
HRESULT SystemDetails::GetCurrentWorkingDirectory(std::filesystem::path& cwd)
{
WCHAR path[MAX_PATH];
DWORD retval = 0L;
Expand All @@ -1705,17 +1705,17 @@ HRESULT SystemDetails::GetCurrentWorkingDirectory(std::wstring& strCWD)
}
if (retval > MAX_PATH)
{
CBinaryBuffer buffer;
buffer.SetCount(retval);
if (!(retval = GetCurrentDirectory(retval, buffer.GetP<WCHAR>())))
Buffer<WCHAR> buffer;
buffer.resize(retval);
if (!(retval = GetCurrentDirectory(retval, buffer.get())))
{
return HRESULT_FROM_WIN32(GetLastError());
}
strCWD.assign(buffer.GetP<WCHAR>(), retval);
cwd = std::filesystem::path(std::wstring_view(buffer.get(), retval)).lexically_normal();
}
else
{
strCWD.assign(path, retval);
cwd = std::filesystem::path(std::wstring_view(path, retval)).lexically_normal();
}
return S_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OrcLib/SystemDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ORCLIB_API SystemDetails
static HRESULT GetSystemLanguage(std::wstring& strLocale);
static HRESULT GetUserLanguage(std::wstring& strLocale);

static HRESULT GetCurrentWorkingDirectory(std::wstring& strCMD);
static HRESULT GetCurrentWorkingDirectory(std::filesystem::path& cwd);

static HRESULT GetProcessBinary(std::wstring& strFullPath);

Expand Down

0 comments on commit 60cb64d

Please sign in to comment.