From 811eeef7a6f90535cf31c3bb2a1ca8cf9f7546be Mon Sep 17 00:00:00 2001 From: amir zamani Date: Tue, 20 Sep 2016 14:13:15 +0430 Subject: [PATCH] update os.h to fix filesize() on older win32 _fstat() always fails under older 32bit WinXP/Win2003 targets. _filelength() just works for both WinXP SDK and later Win7+ 32bit targets. --- include/spdlog/details/os.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index ed4f45cd..6d27bc39 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -31,6 +31,7 @@ #endif #include +#include #elif __linux__ @@ -204,9 +205,9 @@ inline size_t filesize(FILE *f) return st.st_size; #else //windows 32 bits - struct _stat st; - if (_fstat(fd, &st) == 0) - return st.st_size; + long ret = _filelength(fd); + if (ret >= 0) + return static_cast(ret); #endif #else // unix