summaryrefslogtreecommitdiff
path: root/cpio
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2020-01-13 14:23:00 +0100
committerMartin Matuska <martin@matuska.org>2020-01-13 16:16:13 +0100
commita11f15860ae39ecdc8173243a211cdafc8ac893c (patch)
tree0c49b30b9e9f1bbda11a24033b1f7161562846d2 /cpio
parentbdea136855bf7d7cb42cc90c6fbe0c1b4719859d (diff)
downloadlibarchive-a11f15860ae39ecdc8173243a211cdafc8ac893c.tar.gz
Windows: use _localtime64_s and _gmtime64_s where appropriate
Diffstat (limited to 'cpio')
-rw-r--r--cpio/cpio.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c
index f8dd62c5..da5c3986 100644
--- a/cpio/cpio.c
+++ b/cpio/cpio.c
@@ -1140,9 +1140,13 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
time_t mtime;
static time_t now;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
if (!now)
time(&now);
@@ -1190,10 +1194,17 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
else
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
#endif
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&mtime, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = mtime;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
- ltime = localtime(&mtime)
+ ltime = localtime(&mtime);
#endif
strftime(date, sizeof(date), fmt, ltime);