use _stat64 only when targetting Win2k or later

This commit is contained in:
- 2017-02-10 10:56:45 +01:00
parent 9cde3f8b2e
commit 19f61b534e

View File

@ -141,7 +141,7 @@ UTIL_STATIC void UTIL_waitForNextTick(UTIL_time_t ticksPerSecond)
/*-**************************************** /*-****************************************
* File functions * File functions
******************************************/ ******************************************/
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K
#define chmod _chmod #define chmod _chmod
typedef struct _stat64 stat_t; typedef struct _stat64 stat_t;
#else #else
@ -172,7 +172,7 @@ UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf)
UTIL_STATIC int UTIL_getFileStat(const char* infilename, stat_t *statbuf) UTIL_STATIC int UTIL_getFileStat(const char* infilename, stat_t *statbuf)
{ {
int r; int r;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K
r = _stat64(infilename, statbuf); r = _stat64(infilename, statbuf);
if (r || !(statbuf->st_mode & S_IFREG)) return 0; /* No good... */ if (r || !(statbuf->st_mode & S_IFREG)) return 0; /* No good... */
#else #else
@ -186,7 +186,7 @@ UTIL_STATIC int UTIL_getFileStat(const char* infilename, stat_t *statbuf)
UTIL_STATIC U64 UTIL_getFileSize(const char* infilename) UTIL_STATIC U64 UTIL_getFileSize(const char* infilename)
{ {
int r; int r;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K
struct _stat64 statbuf; struct _stat64 statbuf;
r = _stat64(infilename, &statbuf); r = _stat64(infilename, &statbuf);
if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */
@ -212,7 +212,7 @@ UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFi
UTIL_STATIC int UTIL_doesFileExists(const char* infilename) UTIL_STATIC int UTIL_doesFileExists(const char* infilename)
{ {
int r; int r;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K
struct _stat64 statbuf; struct _stat64 statbuf;
r = _stat64(infilename, &statbuf); r = _stat64(infilename, &statbuf);
if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */
@ -228,7 +228,7 @@ UTIL_STATIC int UTIL_doesFileExists(const char* infilename)
UTIL_STATIC U32 UTIL_isDirectory(const char* infilename) UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
{ {
int r; int r;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K
struct _stat64 statbuf; struct _stat64 statbuf;
r = _stat64(infilename, &statbuf); r = _stat64(infilename, &statbuf);
if (!r && (statbuf.st_mode & _S_IFDIR)) return 1; if (!r && (statbuf.st_mode & _S_IFDIR)) return 1;