From: Martin Matuska Date: Fri, 14 Jul 2023 10:33:26 +0000 (+0200) Subject: unzip: fix multi-platform handling of stat mtime X-Git-Tag: v3.7.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0615587a45f328c559298c02bde1007c040a193f;p=thirdparty%2Flibarchive.git unzip: fix multi-platform handling of stat mtime --- diff --git a/unzip/bsdunzip.c b/unzip/bsdunzip.c index 319e7eaa6..d75ca490f 100644 --- a/unzip/bsdunzip.c +++ b/unzip/bsdunzip.c @@ -635,10 +635,27 @@ recheck: if (lstat(*path, &sb) == 0) { if (u_opt || f_opt) { /* check if up-to-date */ - if (S_ISREG(sb.st_mode) && - (sb.st_mtim.tv_sec > mtime.tv_sec || + if (S_ISREG(sb.st_mode) && ( +#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC + sb.st_mtimespec.tv_sec > mtime.tv_sec || + (sb.st_mtimespec.tv_sec == mtime.tv_sec && + sb.st_mtimespec.tv_nsec >= mtime.tv_nsec) +#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC + sb.st_mtim.tv_sec > mtime.tv_sec || (sb.st_mtim.tv_sec == mtime.tv_sec && - sb.st_mtim.tv_nsec >= mtime.tv_nsec))) + sb.st_mtim.tv_nsec >= mtime.tv_nsec) +#elif HAVE_STRUCT_STAT_ST_MTIME_N + sb.st_mtime > mtime.tv_sec || + (sb.st_mtime == mtime.tv_sec && + sb.st_mtime_n => mtime.tv_nsec) +#elif HAVE_STRUCT_STAT_ST_MTIME_USEC + sb.st_mtime > mtime.tv_sec || + (sb.st_mtime == mtime.tv_sec && + sb.st_mtime_usec * 1000 => mtime.tv_nsec) +#else + sb.st_mtime > mtime.tv_sec +#endif + )) return; (void)unlink(*path); } else if (o_opt) {