Handy fix for handling of handles.

This commit is contained in:
Victor Zverovich 2014-09-12 12:37:32 -07:00
parent cb7caa540f
commit 225b757b50

View File

@ -132,7 +132,8 @@ void fmt::File::close() {
fmt::LongLong fmt::File::size() const { fmt::LongLong fmt::File::size() const {
#ifdef _WIN32 #ifdef _WIN32
LARGE_INTEGER size = {}; LARGE_INTEGER size = {};
if (!FMT_SYSTEM(GetFileSizeEx(_get_osfhandle(fd_), &size))) HANDLE handle = reinterpret_cast<HANDLE>(_get_osfhandle(fd_));
if (!FMT_SYSTEM(GetFileSizeEx(handle, &size)))
throw WindowsError(GetLastError(), "cannot get file size"); throw WindowsError(GetLastError(), "cannot get file size");
FMT_STATIC_ASSERT(sizeof(fmt::LongLong) >= sizeof(size.QuadPart), FMT_STATIC_ASSERT(sizeof(fmt::LongLong) >= sizeof(size.QuadPart),
"return type of File::size is not large enough"); "return type of File::size is not large enough");