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. <sys/stat.h> is required for VS2013 or before.
This commit is contained in:
Kelvin Lee 2020-11-29 09:55:45 +11:00
parent 391df5d4c0
commit a7353aa7f1

View File

@ -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 <sys/stat.h>
#endif
@ -2747,9 +2747,14 @@ void FrameRegisterClass () {
// TODO: FIXME: Util_TestFileExists()
static bool FileExists(std::string strFilename)
{
#ifdef _MSC_VER
struct _stat64 stFileInfo;
int intStat = _stat64(strFilename.c_str(), &stFileInfo);
#else
struct stat stFileInfo;
int intStat = stat(strFilename.c_str(), &stFileInfo);
return (intStat == 0) ? true : false;
#endif
return (intStat == 0);
}
//===========================================================================