]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Use statbuf->st_mtim Again
authorW. Felix Handte <w@felixhandte.com>
Wed, 4 Dec 2019 15:25:07 +0000 (10:25 -0500)
committerW. Felix Handte <w@felixhandte.com>
Mon, 23 Dec 2019 18:24:28 +0000 (13:24 -0500)
programs/util.c

index 0fc95512ea2f0d2bc2cd96302d773176190d9531..0751bf3ca2e2f1383bfb7db19e83f65554e67e26 100644 (file)
@@ -145,20 +145,20 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf)
         return -1;
 
     /* set access and modification times */
-#if defined(_WIN32) || (PLATFORM_POSIX_VERSION < 200809L)
+#if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime)
+    {
+        /* (atime, mtime) */
+        struct timespec timebuf[2] = { {0, UTIME_NOW} };
+        timebuf[1] = statbuf->st_mtim;
+        res += utimensat(AT_FDCWD, filename, timebuf, 0);
+    }
+#else
     {
         struct utimbuf timebuf;
         timebuf.actime = time(NULL);
         timebuf.modtime = statbuf->st_mtime;
         res += utime(filename, &timebuf);
     }
-#else
-    {
-        /* (atime, mtime) */
-        struct timespec timebuf[2] = { {0, UTIME_NOW} };
-        timebuf[1].tv_sec = statbuf->st_mtime;
-        res += utimensat(AT_FDCWD, filename, timebuf, 0);
-    }
 #endif
 
 #if !defined(_WIN32)