Commit a3a1c93f authored by Laszlo Csomor's avatar Laszlo Csomor

io_win32_unittest: remove incorrect error check

Unlike GetEnvironmentVariableW,
GetCurrentDirectoryW doesn't set
ERROR_INSUFFICIENT_BUFFER.
parent eb3bd6ec
...@@ -122,7 +122,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { ...@@ -122,7 +122,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
// to be no API function to do that conversion directly. // to be no API function to do that conversion directly.
// GetEnvironmentVariableW retrieves an UTF-16-encoded text, which we need // GetEnvironmentVariableW retrieves an UTF-16-encoded text, which we need
// to convert to UTF-8. // to convert to UTF-8.
return strings::wcs_to_mbs(wcs.get(), result, true); return strings::wcs_to_utf8(wcs.get(), result);
} else { } else {
return false; return false;
} }
...@@ -130,7 +130,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { ...@@ -130,7 +130,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
bool GetCwdAsUtf8(string* result) { bool GetCwdAsUtf8(string* result) {
DWORD size = ::GetCurrentDirectoryW(0, NULL); DWORD size = ::GetCurrentDirectoryW(0, NULL);
if (size > 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { if (size > 0) {
scoped_array<WCHAR> wcs(new WCHAR[size]); scoped_array<WCHAR> wcs(new WCHAR[size]);
::GetCurrentDirectoryW(size, wcs.get()); ::GetCurrentDirectoryW(size, wcs.get());
// GetCurrentDirectoryA retrieves an Active-Code-Page-encoded text which // GetCurrentDirectoryA retrieves an Active-Code-Page-encoded text which
...@@ -138,7 +138,7 @@ bool GetCwdAsUtf8(string* result) { ...@@ -138,7 +138,7 @@ bool GetCwdAsUtf8(string* result) {
// to be no API function to do that conversion directly. // to be no API function to do that conversion directly.
// GetCurrentDirectoryW retrieves an UTF-16-encoded text, which we need // GetCurrentDirectoryW retrieves an UTF-16-encoded text, which we need
// to convert to UTF-8. // to convert to UTF-8.
return strings::wcs_to_mbs(wcs.get(), result, true); return strings::wcs_to_utf8(wcs.get(), result);
} else { } else {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment