]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
use _stati64() in UTIL_getFileSize() when compiling with mingw, get rid of introduces... 540/head
authords77 <ds77@users.noreply.github.com>
Fri, 10 Feb 2017 17:37:57 +0000 (18:37 +0100)
committerds77 <ds77@users.noreply.github.com>
Fri, 10 Feb 2017 17:37:57 +0000 (18:37 +0100)
programs/util.h

index fe3d84489224faa75350fb296e2242ed31a037ed..b121791065af059c3aea7ce9ce97dc46e5f7ca53 100644 (file)
@@ -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;