Avoid repeated call to GetLastError in file::size (#4522)

This commit is contained in:
Victor Chernyakin 2025-09-03 08:38:31 -07:00 committed by GitHub
parent f17b9aa44c
commit 80549a630e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -251,7 +251,7 @@ auto file::size() const -> long long {
if (size_lower == INVALID_FILE_SIZE) {
DWORD error = GetLastError();
if (error != NO_ERROR)
FMT_THROW(windows_error(GetLastError(), "cannot get file size"));
FMT_THROW(windows_error(error, "cannot get file size"));
}
unsigned long long long_size = size_upper;
return (long_size << sizeof(DWORD) * CHAR_BIT) | size_lower;