]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Introduce Dedicated Helper to Call stat()
authorW. Felix Handte <w@felixhandte.com>
Wed, 5 Aug 2020 04:09:29 +0000 (00:09 -0400)
committerW. Felix Handte <w@felixhandte.com>
Wed, 5 Aug 2020 04:21:21 +0000 (00:21 -0400)
programs/util.c
programs/util.h

index 2493a4adcb1f7e0be21622e13cada02ed65a8889..c172150d9c190d51fafde392c7c46f4d32555455 100644 (file)
@@ -99,6 +99,17 @@ int g_utilDisplayLevel;
 *  Functions
 ***************************************/
 
+int UTIL_stat(const char* filename, stat_t* statbuf)
+{
+#if defined(_MSC_VER)
+    return !_stat64(filename, statbuf);
+#elif defined(__MINGW32__) && defined (__MSVCRT__)
+    return !_stati64(filename, statbuf);
+#else
+    return !stat(filename, statbuf);
+#endif
+}
+
 int UTIL_fileExist(const char* filename)
 {
     stat_t statbuf;
index 580266e7182862f31dab624c129226459b57bda0..0b58dfbbfab9a7fd2e25f8f2565598c68f0805a5 100644 (file)
@@ -100,6 +100,8 @@ extern int g_utilDisplayLevel;
 #if defined(_MSC_VER)
     typedef struct __stat64 stat_t;
     typedef int mode_t;
+#elif defined(__MINGW32__) && defined (__MSVCRT__)
+    typedef struct _stati64 stat_t;
 #else
     typedef struct stat stat_t;
 #endif
@@ -113,6 +115,11 @@ extern int g_utilDisplayLevel;
 #define STRDUP(s) strdup(s)
 #endif
 
+/**
+ * Calls platform's equivalent of stat() on filename and writes info to statbuf.
+ * Returns success (1) or failure (0).
+ */
+int UTIL_stat(const char* filename, stat_t* statbuf);
 int UTIL_fileExist(const char* filename);
 int UTIL_isRegularFile(const char* infilename);
 int UTIL_isDirectory(const char* infilename);