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

Go to the source code of this file.

Functions

ZIP_EXTERN int zip_stat_index (zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
 

Function Documentation

◆ zip_stat_index()

ZIP_EXTERN int zip_stat_index ( zip_t za,
zip_uint64_t  index,
zip_flags_t  flags,
zip_stat_t st 
)

Definition at line 39 of file zip_stat_index.c.

39  {
40  const char *name;
41  zip_dirent_t *de;
42 
43  if ((de = _zip_get_dirent(za, index, flags, NULL)) == NULL)
44  return -1;
45 
46  if ((name = zip_get_name(za, index, flags)) == NULL)
47  return -1;
48 
49 
50  if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) {
51  zip_entry_t *entry = za->entry + index;
52 
53  if (zip_source_stat(entry->source, st) < 0) {
55  return -1;
56  }
57 
58  if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
59  st->mtime = de->last_mod;
60  st->valid |= ZIP_STAT_MTIME;
61  }
62  }
63  else {
64  zip_stat_init(st);
65 
66  st->crc = de->crc;
67  st->size = de->uncomp_size;
68  st->mtime = de->last_mod;
69  st->comp_size = de->comp_size;
73  }
74 
75  st->index = index;
76  st->name = name;
78 
79  return 0;
80 }
#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_STAT_NAME
Definition: zip.h:290
#define ZIP_ER_CHANGED
Definition: zip.h:120
#define ZIP_STAT_SIZE
Definition: zip.h:292
#define ZIP_STAT_COMP_METHOD
Definition: zip.h:296
ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull)
Definition: zip_stat_init.c:40
ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
Definition: zip_get_name.c:41
ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull)
#define ZIP_STAT_ENCRYPTION_METHOD
Definition: zip.h:297
#define ZIP_STAT_COMP_SIZE
Definition: zip.h:293
#define ZIP_STAT_MTIME
Definition: zip.h:294
#define ZIP_STAT_INDEX
Definition: zip.h:291
#define ZIP_FL_UNCHANGED
Definition: zip.h:79
#define ZIP_STAT_CRC
Definition: zip.h:295
const char * name
Definition: op.c:541
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
Definition: zipcmp.c:77
Definition: z80asm.h:102
time_t last_mod
Definition: zipint.h:337
zip_uint64_t uncomp_size
Definition: zipint.h:340
zip_uint32_t crc
Definition: zipint.h:338
zip_int32_t comp_method
Definition: zipint.h:336
zip_uint64_t comp_size
Definition: zipint.h:339
zip_uint16_t encryption_method
Definition: zipint.h:350
bool crc_valid
Definition: zipint.h:331
Definition: zipint.h:408
time_t mtime
Definition: zip.h:306
zip_uint16_t encryption_method
Definition: zip.h:309
zip_uint64_t index
Definition: zip.h:303
const char *_Nullable name
Definition: zip.h:302
zip_uint64_t valid
Definition: zip.h:301
zip_uint16_t comp_method
Definition: zip.h:308
zip_uint64_t comp_size
Definition: zip.h:305
zip_uint32_t crc
Definition: zip.h:307
zip_uint64_t size
Definition: zip.h:304
zip_error_t error
Definition: zipint.h:281
zip_entry_t * entry
Definition: zipint.h:294
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
uint16_t zip_uint16_t
Definition: zipconf.h:35
#define ZIP_ENTRY_DATA_CHANGED(x)
Definition: zipint.h:476
#define ZIP_DIRENT_LAST_MOD
Definition: zipint.h:321
zip_t * za
Definition: ziptool.c:79

References _zip_get_dirent(), zip_stat::comp_method, zip_dirent::comp_method, zip_stat::comp_size, zip_dirent::comp_size, zip_stat::crc, zip_dirent::crc, zip_dirent::crc_valid, zip_stat::encryption_method, zip_dirent::encryption_method, zip::entry, zip::error, flags, zip_stat::index, zip_dirent::last_mod, zip_stat::mtime, name, zip_stat::name, NULL, zip_stat::size, zip_dirent::uncomp_size, zip_stat::valid, za, ZIP_DIRENT_LAST_MOD, ZIP_ENTRY_DATA_CHANGED, ZIP_ER_CHANGED, zip_error_set(), ZIP_FL_UNCHANGED, zip_get_name(), zip_source_stat(), ZIP_STAT_COMP_METHOD, ZIP_STAT_COMP_SIZE, ZIP_STAT_CRC, ZIP_STAT_ENCRYPTION_METHOD, ZIP_STAT_INDEX, zip_stat_init(), ZIP_STAT_MTIME, ZIP_STAT_NAME, and ZIP_STAT_SIZE.

Referenced by _zip_source_zip_new(), confirm_replace(), list_zip(), rz_io_zip_alloc_zipfileobj(), rz_io_zip_get_by_file_idx(), rz_io_zip_get_files(), rz_io_zip_slurp_file(), zip_stat(), and zstat().