From a7353aa7f14909f803ed729a0f7037c68694a44b Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Sun, 29 Nov 2020 09:55:45 +1100 Subject: [PATCH] Use _stat64() to support file size >2G 1. Newer VC runtime stat(), when using 32-bit file size, returns error if file size is >2G. For file existence check, using 64-bit file size is more accurate as files bigger than 2G would be reported as non-existing otherwise. 2. is required for VS2013 or before. --- source/Windows/WinFrame.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index de26836d..6a77627f 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -58,7 +58,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../resource/resource.h" #include "Configuration/PropertySheet.h" #include "Debugger/Debug.h" -#if _MSC_VER <= 1500 // VS2008 only (cl.exe v15.00) +#if _MSC_VER < 1900 // VS2013 or before (cl.exe v18.x or before) #include #endif @@ -2746,10 +2746,15 @@ void FrameRegisterClass () { //=========================================================================== // TODO: FIXME: Util_TestFileExists() static bool FileExists(std::string strFilename) -{ - struct stat stFileInfo; - int intStat = stat(strFilename.c_str(),&stFileInfo); - return (intStat == 0) ? true : false; +{ +#ifdef _MSC_VER + struct _stat64 stFileInfo; + int intStat = _stat64(strFilename.c_str(), &stFileInfo); +#else + struct stat stFileInfo; + int intStat = stat(strFilename.c_str(), &stFileInfo); +#endif + return (intStat == 0); } //===========================================================================