VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_file_set_mtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/libzip/zip_file_set_mtime.c')
-rw-r--r--src/Common/libzip/zip_file_set_mtime.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/Common/libzip/zip_file_set_mtime.c b/src/Common/libzip/zip_file_set_mtime.c
index 4126f5a1..e60f7a9a 100644
--- a/src/Common/libzip/zip_file_set_mtime.c
+++ b/src/Common/libzip/zip_file_set_mtime.c
@@ -1,6 +1,6 @@
/*
zip_file_set_mtime.c -- set modification time of entry.
- Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
@@ -33,19 +33,12 @@
#include "zipint.h"
-ZIP_EXTERN int
-zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
- time_t mtime;
- mtime = _zip_d2u_time(dtime, ddate);
- return zip_file_set_mtime(za, idx, mtime, flags);
-}
-
-ZIP_EXTERN int
-zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
+static int zip_file_set_time(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags, time_t *mtime) {
zip_entry_t *e;
- if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
+ if (_zip_get_dirent(za, idx, 0, NULL) == NULL) {
return -1;
+ }
if (ZIP_IS_RDONLY(za)) {
zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
@@ -70,8 +63,31 @@ zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)
}
}
- e->changes->last_mod = mtime;
+ e->changes->last_mod.time = dtime;
+ e->changes->last_mod.date = ddate;
+ if (mtime != NULL) {
+ e->changes->last_mod_mtime = *mtime;
+ e->changes->last_mod_mtime_valid = true;
+ }
+ else {
+ e->changes->last_mod_mtime_valid = false;
+ }
e->changes->changed |= ZIP_DIRENT_LAST_MOD;
return 0;
}
+
+ZIP_EXTERN int zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
+ return zip_file_set_time(za, idx, dtime, ddate, flags, NULL);
+}
+
+
+ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
+ zip_dostime_t dostime;
+
+ if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) {
+ return -1;
+ }
+
+ return zip_file_set_time(za, idx, dostime.time, dostime.date, flags, &mtime);
+}