From 26d7c27bee77ed6320a3f60492ed1db1c20dba9b Mon Sep 17 00:00:00 2001 From: Adi Lester Date: Tue, 27 Nov 2018 14:16:25 +0200 Subject: [PATCH] Use _filelengthi64 instead of _fstat64 to calculate file size on x64 machines For some reason, `_fstat64` fails with errno 22 on Windows Server 2003 x64 when compiled using the `v141_xp` toolset. Using `_filelengthi64` instead solves this issue --- include/spdlog/details/os.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index f2422904..573224ad 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -210,10 +210,10 @@ inline size_t filesize(FILE *f) #if defined(_WIN32) && !defined(__CYGWIN__) int fd = _fileno(f); #if _WIN64 // 64 bits - struct _stat64 st; - if (_fstat64(fd, &st) == 0) + long long ret = _filelengthi64(fd); + if (ret >= 0) { - return st.st_size; + return static_cast(ret); } #else // windows 32 bits