Skip to content

Commit

Permalink
io_win32_unittest: remove incorrect error check
Browse files Browse the repository at this point in the history
Unlike GetEnvironmentVariableW,
GetCurrentDirectoryW doesn't set
ERROR_INSUFFICIENT_BUFFER.
  • Loading branch information
laszlocsomor committed Dec 7, 2017
1 parent eb3bd6e commit a3a1c93
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/google/protobuf/stubs/io_win32_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,23 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
// to be no API function to do that conversion directly.
// GetEnvironmentVariableW retrieves an UTF-16-encoded text, which we need
// to convert to UTF-8.
return strings::wcs_to_mbs(wcs.get(), result, true);
return strings::wcs_to_utf8(wcs.get(), result);
} else {
return false;
}
}

bool GetCwdAsUtf8(string* result) {
DWORD size = ::GetCurrentDirectoryW(0, NULL);
if (size > 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
if (size > 0) {
scoped_array<WCHAR> wcs(new WCHAR[size]);
::GetCurrentDirectoryW(size, wcs.get());
// GetCurrentDirectoryA retrieves an Active-Code-Page-encoded text which
// we'd first need to convert to UTF-16 then to UTF-8, because there seems
// to be no API function to do that conversion directly.
// GetCurrentDirectoryW retrieves an UTF-16-encoded text, which we need
// to convert to UTF-8.
return strings::wcs_to_mbs(wcs.get(), result, true);
return strings::wcs_to_utf8(wcs.get(), result);
} else {
return false;
}
Expand Down

0 comments on commit a3a1c93

Please sign in to comment.