From 45f0c207ab8e3955a6068cc845eceb175623fd63 Mon Sep 17 00:00:00 2001 From: ds77 Date: Fri, 10 Feb 2017 18:37:57 +0100 Subject: [PATCH] use _stati64() in UTIL_getFileSize() when compiling with mingw, get rid of introduces previously preprocessor checks. --- programs/util.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/programs/util.h b/programs/util.h index fe3d84489..b12179106 100644 --- a/programs/util.h +++ b/programs/util.h @@ -141,7 +141,7 @@ UTIL_STATIC void UTIL_waitForNextTick(UTIL_time_t ticksPerSecond) /*-**************************************** * File functions ******************************************/ -#if defined(_MSC_VER) || defined(__MINGW32__) && defined(__MSVCRT__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K +#if defined(_MSC_VER) #define chmod _chmod typedef struct __stat64 stat_t; #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) { int r; -#if defined(_MSC_VER) || defined(__MINGW32__) && defined(__MSVCRT__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K +#if defined(_MSC_VER) r = _stat64(infilename, statbuf); if (r || !(statbuf->st_mode & S_IFREG)) return 0; /* No good... */ #else @@ -186,10 +186,14 @@ UTIL_STATIC int UTIL_getFileStat(const char* infilename, stat_t *statbuf) UTIL_STATIC U64 UTIL_getFileSize(const char* infilename) { int r; -#if defined(_MSC_VER) || defined(__MINGW32__) && defined(__MSVCRT__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K - struct __stat64 statbuf; +#if defined(_MSC_VER) + struct _stat64 statbuf; r = _stat64(infilename, &statbuf); if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ +#elif defined(__MINGW32__) && defined (__MSVCRT__) + struct _stati64 statbuf; + r = _stati64(infilename, &statbuf); + if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ #else struct stat statbuf; r = stat(infilename, &statbuf); @@ -212,7 +216,7 @@ UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFi UTIL_STATIC int UTIL_doesFileExists(const char* infilename) { int r; -#if defined(_MSC_VER) || defined(__MINGW32__) && defined(__MSVCRT__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K +#if defined(_MSC_VER) struct __stat64 statbuf; r = _stat64(infilename, &statbuf); if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ @@ -228,7 +232,7 @@ UTIL_STATIC int UTIL_doesFileExists(const char* infilename) UTIL_STATIC U32 UTIL_isDirectory(const char* infilename) { int r; -#if defined(_MSC_VER) || defined(__MINGW32__) && defined(__MSVCRT__) && _WIN32_WINNT >= _WIN32_WINNT_WIN2K +#if defined(_MSC_VER) struct __stat64 statbuf; r = _stat64(infilename, &statbuf); if (!r && (statbuf.st_mode & _S_IFDIR)) return 1;