From: W. Felix Handte Date: Wed, 4 Dec 2019 15:25:07 +0000 (-0500) Subject: Use statbuf->st_mtim Again X-Git-Tag: v1.4.5^2~127^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5af8cb7aea8d890b4801e50e5274371510f2cf33;p=thirdparty%2Fzstd.git Use statbuf->st_mtim Again --- diff --git a/programs/util.c b/programs/util.c index 0fc95512e..0751bf3ca 100644 --- a/programs/util.c +++ b/programs/util.c @@ -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)