Rizin
unix-like reverse engineering framework and cli tools
zip_file_set_mtime.c File Reference
#include "zipint.h"

Go to the source code of this file.

Functions

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)
 
ZIP_EXTERN int zip_file_set_mtime (zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)
 

Function Documentation

◆ zip_file_set_dostime()

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 
)

Definition at line 37 of file zip_file_set_mtime.c.

37  {
38  time_t mtime;
39  mtime = _zip_d2u_time(dtime, ddate);
40  return zip_file_set_mtime(za, idx, mtime, flags);
41 }
int idx
Definition: setup.py:197
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
int time_t
Definition: sftypes.h:66
time_t _zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate)
Definition: zip_dirent.c:1004
ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)
zip_t * za
Definition: ziptool.c:79

References _zip_d2u_time(), flags, setup::idx, za, and zip_file_set_mtime().

Referenced by set_file_dostime().

◆ zip_file_set_mtime()

ZIP_EXTERN int zip_file_set_mtime ( zip_t za,
zip_uint64_t  idx,
time_t  mtime,
zip_flags_t  flags 
)

Definition at line 44 of file zip_file_set_mtime.c.

44  {
45  zip_entry_t *e;
46 
47  if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
48  return -1;
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  e = za->entry + idx;
56 
57  if (e->orig != NULL && e->orig->encryption_method == ZIP_EM_TRAD_PKWARE && !ZIP_ENTRY_CHANGED(e, ZIP_DIRENT_ENCRYPTION_METHOD) && !ZIP_ENTRY_DATA_CHANGED(e)) {
59  return -1;
60  }
61 
62  if (e->changes == NULL) {
63  if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
65  return -1;
66  }
67  }
68 
69  e->changes->last_mod = mtime;
70  e->changes->changed |= ZIP_DIRENT_LAST_MOD;
71 
72  return 0;
73 }
#define e(frag)
#define NULL
Definition: cris-opc.c:27
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
#define ZIP_ER_MEMORY
Definition: zip.h:119
#define ZIP_EM_TRAD_PKWARE
Definition: zip.h:178
#define ZIP_ER_RDONLY
Definition: zip.h:130
#define ZIP_ER_OPNOTSUPP
Definition: zip.h:133
Definition: zipint.h:408
zip_error_t error
Definition: zipint.h:281
zip_entry_t * entry
Definition: zipint.h:294
zip_dirent_t * _zip_dirent_clone(const zip_dirent_t *sde)
Definition: zip_dirent.c:215
zip_dirent_t * _zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error)
Definition: zip_dirent.c:1064
#define ZIP_IS_RDONLY(za)
Definition: zipint.h:479
#define ZIP_ENTRY_DATA_CHANGED(x)
Definition: zipint.h:476
#define ZIP_ENTRY_CHANGED(e, f)
Definition: zipint.h:475
#define ZIP_DIRENT_LAST_MOD
Definition: zipint.h:321
#define ZIP_DIRENT_ENCRYPTION_METHOD
Definition: zipint.h:322

References _zip_dirent_clone(), _zip_get_dirent(), e, zip::entry, zip::error, setup::idx, NULL, za, ZIP_DIRENT_ENCRYPTION_METHOD, ZIP_DIRENT_LAST_MOD, ZIP_EM_TRAD_PKWARE, ZIP_ENTRY_CHANGED, ZIP_ENTRY_DATA_CHANGED, ZIP_ER_MEMORY, ZIP_ER_OPNOTSUPP, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.

Referenced by set_file_mtime(), set_file_mtime_all(), and zip_file_set_dostime().