Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-10-01 22:47:28 +02:00
parent 40003c4054
commit ca4e9d069f
3 changed files with 393 additions and 397 deletions

View File

@ -1,4 +1,4 @@
/* /*
SPDX-License-Identifier: MIT SPDX-License-Identifier: MIT
Copyright © 1991-2023 Amebis Copyright © 1991-2023 Amebis
Copyright © 2016 GÉANT Copyright © 2016 GÉANT

View File

@ -1056,7 +1056,7 @@ namespace winstd
} }
/// ///
/// Returns the Windows error number /// Returns the error number
/// ///
error_type number() const error_type number() const
{ {

View File

@ -31,7 +31,7 @@ static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
// Copy from stack. // Copy from stack.
sName.assign(szStackBuffer, ulSize); sName.assign(szStackBuffer, ulSize);
return TRUE; return TRUE;
} else { }
if (::GetLastError() == ERROR_MORE_DATA) { if (::GetLastError() == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry. // Allocate buffer on heap and retry.
std::unique_ptr<char[]> szBuffer(new char[ulSize]); std::unique_ptr<char[]> szBuffer(new char[ulSize]);
@ -40,8 +40,6 @@ static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
return TRUE; return TRUE;
} }
} }
}
return FALSE; return FALSE;
} }
@ -63,7 +61,7 @@ static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
// Copy from stack. // Copy from stack.
sName.assign(szStackBuffer, ulSize); sName.assign(szStackBuffer, ulSize);
return TRUE; return TRUE;
} else { }
if (::GetLastError() == ERROR_MORE_DATA) { if (::GetLastError() == ERROR_MORE_DATA) {
// Allocate buffer on heap and retry. // Allocate buffer on heap and retry.
std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[ulSize]); std::unique_ptr<wchar_t[]> szBuffer(new wchar_t[ulSize]);
@ -72,8 +70,6 @@ static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std:
return TRUE; return TRUE;
} }
} }
}
return FALSE; return FALSE;
} }