mirror of https://github.com/PCSX2/pcsx2.git
Deps: Update to libzip 1.11.2
This commit is contained in:
parent
981fedfdd1
commit
58ab271fc1
|
@ -123,14 +123,64 @@ typedef char bool;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FSEEKO
|
|
||||||
#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
|
#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__SEEK64)
|
||||||
|
/* Windows API using int64 */
|
||||||
|
typedef zip_int64_t zip_off_t;
|
||||||
|
typedef struct _stat64 zip_os_stat_t;
|
||||||
|
#define zip_os_stat _stat64
|
||||||
|
#define zip_os_fstat _fstat64
|
||||||
|
#define zip_os_seek _fseeki64
|
||||||
|
#define ZIP_FSEEK_MAX ZIP_INT64_MAX
|
||||||
|
#define ZIP_FSEEK_MIN ZIP_INT64_MIN
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Normal API */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
typedef struct stat zip_os_stat_t;
|
||||||
|
#define zip_os_fstat fstat
|
||||||
|
#define zip_os_stat stat
|
||||||
|
|
||||||
|
#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
|
||||||
|
/* Using off_t */
|
||||||
|
typedef off_t zip_off_t;
|
||||||
|
#if SIZEOF_OFF_T == 8
|
||||||
|
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
||||||
|
#define ZIP_OFF_MIN ZIP_INT64_MIN
|
||||||
|
#elif SIZEOF_OFF_T == 4
|
||||||
|
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
||||||
|
#define ZIP_OFF_MIN ZIP_INT32_MIN
|
||||||
|
#elif SIZEOF_OFF_T == 2
|
||||||
|
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
||||||
|
#define ZIP_OFF_MIN ZIP_INT16_MIN
|
||||||
|
#else
|
||||||
|
#error unsupported size of off_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ZIP_FSEEK_MAX ZIP_OFF_MAX
|
||||||
|
#define ZIP_FSEEK_MIN ZIP_OFF_MIN
|
||||||
|
|
||||||
|
#define zip_os_fseek fseeko
|
||||||
|
#define zip_os_ftell ftello
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Using long */
|
||||||
|
typedef long zip_off_t;
|
||||||
|
#include <limits.h>
|
||||||
|
#define ZIP_FSEEK_MAX LONG_MAX
|
||||||
|
#define ZIP_FSEEK_MIN LONG_MIN
|
||||||
|
|
||||||
|
#define zip_os_fseek fseek
|
||||||
|
#define zip_os_ftell ftell
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_FTELLO
|
#ifndef HAVE_FTELLO
|
||||||
#define ftello(s) ((long)ftell((s)))
|
#define ftello(s) ((long)ftell((s)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LOCALTIME_S
|
#ifdef HAVE_LOCALTIME_S
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Windows is incompatible to the C11 standard, hurray! */
|
/* Windows is incompatible to the C11 standard, hurray! */
|
||||||
|
@ -179,27 +229,6 @@ typedef char bool;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SIZEOF_OFF_T == 8
|
|
||||||
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
|
||||||
#define ZIP_OFF_MIN ZIP_INT64_MIN
|
|
||||||
#elif SIZEOF_OFF_T == 4
|
|
||||||
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
|
||||||
#define ZIP_OFF_MIN ZIP_INT32_MIN
|
|
||||||
#elif SIZEOF_OFF_T == 2
|
|
||||||
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
|
||||||
#define ZIP_OFF_MIN ZIP_INT16_MIN
|
|
||||||
#else
|
|
||||||
#error unsupported size of off_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
|
|
||||||
#define ZIP_FSEEK_MAX ZIP_OFF_MAX
|
|
||||||
#define ZIP_FSEEK_MIN ZIP_OFF_MIN
|
|
||||||
#else
|
|
||||||
#include <limits.h>
|
|
||||||
#define ZIP_FSEEK_MAX LONG_MAX
|
|
||||||
#define ZIP_FSEEK_MIN LONG_MIN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
#if SIZEOF_SIZE_T == 8
|
#if SIZEOF_SIZE_T == 8
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "zip.h"
|
|
||||||
#include "zipint.h"
|
#include "zipint.h"
|
||||||
|
|
||||||
static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency);
|
static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency);
|
||||||
|
@ -283,6 +282,7 @@ _zip_dirent_init(zip_dirent_t *de) {
|
||||||
de->cloned = 0;
|
de->cloned = 0;
|
||||||
|
|
||||||
de->crc_valid = true;
|
de->crc_valid = true;
|
||||||
|
de->last_mod_mtime_valid = false;
|
||||||
de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8);
|
de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8);
|
||||||
de->version_needed = 10; /* 1.0 */
|
de->version_needed = 10; /* 1.0 */
|
||||||
de->bitflags = 0;
|
de->bitflags = 0;
|
||||||
|
@ -1264,3 +1264,12 @@ zip_dirent_check_consistency(zip_dirent_t *dirent) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de) {
|
||||||
|
if (!de->last_mod_mtime_valid) {
|
||||||
|
de->last_mod_mtime = _zip_d2u_time(&de->last_mod);
|
||||||
|
de->last_mod_mtime_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return de->last_mod_mtime;
|
||||||
|
}
|
|
@ -33,8 +33,7 @@
|
||||||
|
|
||||||
#include "zipint.h"
|
#include "zipint.h"
|
||||||
|
|
||||||
ZIP_EXTERN int
|
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_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
|
|
||||||
zip_entry_t *e;
|
zip_entry_t *e;
|
||||||
|
|
||||||
if (_zip_get_dirent(za, idx, 0, NULL) == NULL) {
|
if (_zip_get_dirent(za, idx, 0, NULL) == NULL) {
|
||||||
|
@ -66,18 +65,29 @@ zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16
|
||||||
|
|
||||||
e->changes->last_mod.time = dtime;
|
e->changes->last_mod.time = dtime;
|
||||||
e->changes->last_mod.date = ddate;
|
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;
|
e->changes->changed |= ZIP_DIRENT_LAST_MOD;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZIP_EXTERN int
|
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_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, 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;
|
zip_dostime_t dostime;
|
||||||
|
|
||||||
if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) {
|
if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return zip_file_set_dostime(za, idx, dostime.time, dostime.date, flags);
|
return zip_file_set_time(za, idx, dostime.time, dostime.date, flags, &mtime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ _zip_new(zip_error_t *error) {
|
||||||
za->nopen_source = za->nopen_source_alloc = 0;
|
za->nopen_source = za->nopen_source_alloc = 0;
|
||||||
za->open_source = NULL;
|
za->open_source = NULL;
|
||||||
za->progress = NULL;
|
za->progress = NULL;
|
||||||
|
za->torrent_mtime = 0;
|
||||||
|
|
||||||
return za;
|
return za;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef S_IWUSR
|
#ifndef S_IWUSR
|
||||||
|
@ -120,7 +119,7 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fseeko((FILE *)f, (off_t)offset, whence) < 0) {
|
if (zip_os_fseek((FILE *)f, (zip_off_t)offset, whence) < 0) {
|
||||||
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,15 +129,15 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
|
_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
|
||||||
struct stat sb;
|
zip_os_stat_t sb;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (ctx->fname) {
|
if (ctx->fname) {
|
||||||
ret = stat(ctx->fname, &sb);
|
ret = zip_os_stat(ctx->fname, &sb);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = fstat(fileno((FILE *)ctx->f), &sb);
|
ret = zip_os_fstat(fileno((FILE *)ctx->f), &sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -168,7 +167,7 @@ _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
|
||||||
|
|
||||||
zip_int64_t
|
zip_int64_t
|
||||||
_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) {
|
_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) {
|
||||||
off_t offset = ftello((FILE *)f);
|
zip_off_t offset = zip_os_ftell((FILE *)f);
|
||||||
|
|
||||||
if (offset < 0) {
|
if (offset < 0) {
|
||||||
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
|
||||||
|
|
|
@ -178,9 +178,9 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct file_clone_range range;
|
struct file_clone_range range;
|
||||||
struct stat st;
|
zip_os_stat_t st;
|
||||||
|
|
||||||
if (fstat(fileno(ctx->f), &st) < 0) {
|
if (zip_os_fstat(fileno(ctx->f), &st) < 0) {
|
||||||
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
|
||||||
ctx->tmpname = NULL;
|
ctx->tmpname = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (fseeko(tfp, (off_t)offset, SEEK_SET) < 0) {
|
if (zip_os_fseek(tfp, (zip_off_t)offset, SEEK_SET) < 0) {
|
||||||
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
|
||||||
(void)fclose(tfp);
|
(void)fclose(tfp);
|
||||||
(void)remove(ctx->tmpname);
|
(void)remove(ctx->tmpname);
|
||||||
|
@ -290,11 +290,11 @@ _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64
|
||||||
static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
|
static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
|
||||||
char *temp;
|
char *temp;
|
||||||
int mode;
|
int mode;
|
||||||
struct stat st;
|
zip_os_stat_t st;
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
|
|
||||||
if (stat(ctx->fname, &st) == 0) {
|
if (zip_os_stat(ctx->fname, &st) == 0) {
|
||||||
mode = st.st_mode;
|
mode = st.st_mode;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -344,7 +344,7 @@ static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (stat(temp, &st) < 0) {
|
if (zip_os_stat(temp, &st) < 0) {
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
|
if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
|
||||||
st->mtime = _zip_d2u_time(&de->last_mod);
|
st->mtime = zip_dirent_get_last_mod_mtime(de);
|
||||||
st->valid |= ZIP_STAT_MTIME;
|
st->valid |= ZIP_STAT_MTIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||||
|
|
||||||
st->crc = de->crc;
|
st->crc = de->crc;
|
||||||
st->size = de->uncomp_size;
|
st->size = de->uncomp_size;
|
||||||
st->mtime = _zip_d2u_time(&de->last_mod);
|
st->mtime = zip_dirent_get_last_mod_mtime(de);
|
||||||
st->comp_size = de->comp_size;
|
st->comp_size = de->comp_size;
|
||||||
st->comp_method = (zip_uint16_t)de->comp_method;
|
st->comp_method = (zip_uint16_t)de->comp_method;
|
||||||
st->encryption_method = de->encryption_method;
|
st->encryption_method = de->encryption_method;
|
||||||
|
@ -97,9 +97,12 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((za->ch_flags & ZIP_AFL_WANT_TORRENTZIP) && (flags & ZIP_FL_UNCHANGED) == 0) {
|
if ((za->ch_flags & ZIP_AFL_WANT_TORRENTZIP) && (flags & ZIP_FL_UNCHANGED) == 0) {
|
||||||
zip_dostime_t dostime = {0xbc00, 0x2198};
|
if (za->torrent_mtime == 0) {
|
||||||
|
zip_dostime_t dostime = {0xbc00, 0x2198};
|
||||||
|
za->torrent_mtime = _zip_d2u_time(&dostime);
|
||||||
|
}
|
||||||
st->comp_method = ZIP_CM_DEFLATE;
|
st->comp_method = ZIP_CM_DEFLATE;
|
||||||
st->mtime = _zip_d2u_time(&dostime);
|
st->mtime = za->torrent_mtime;
|
||||||
st->valid |= ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD;
|
st->valid |= ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD;
|
||||||
st->valid &= ~ZIP_STAT_COMP_SIZE;
|
st->valid &= ~ZIP_STAT_COMP_SIZE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,7 @@ struct zip {
|
||||||
zip_progress_t *progress; /* progress callback for zip_close() */
|
zip_progress_t *progress; /* progress callback for zip_close() */
|
||||||
|
|
||||||
zip_uint32_t* write_crc; /* have _zip_write() compute CRC */
|
zip_uint32_t* write_crc; /* have _zip_write() compute CRC */
|
||||||
|
time_t torrent_mtime;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* file in zip archive, part of API */
|
/* file in zip archive, part of API */
|
||||||
|
@ -346,6 +347,7 @@ struct zip_dirent {
|
||||||
bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */
|
bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */
|
||||||
|
|
||||||
bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */
|
bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */
|
||||||
|
bool last_mod_mtime_valid;
|
||||||
|
|
||||||
zip_uint16_t version_madeby; /* (c) version of creator */
|
zip_uint16_t version_madeby; /* (c) version of creator */
|
||||||
zip_uint16_t version_needed; /* (cl) version needed to extract */
|
zip_uint16_t version_needed; /* (cl) version needed to extract */
|
||||||
|
@ -366,6 +368,8 @@ struct zip_dirent {
|
||||||
zip_uint32_t compression_level; /* level of compression to use (never valid in orig) */
|
zip_uint32_t compression_level; /* level of compression to use (never valid in orig) */
|
||||||
zip_uint16_t encryption_method; /* encryption method, computed from other fields */
|
zip_uint16_t encryption_method; /* encryption method, computed from other fields */
|
||||||
char *password; /* file specific encryption password */
|
char *password; /* file specific encryption password */
|
||||||
|
|
||||||
|
time_t last_mod_mtime; /* cached last_mod in Unix time format */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* zip archive central directory */
|
/* zip archive central directory */
|
||||||
|
@ -553,6 +557,7 @@ int zip_dirent_check_consistency(zip_dirent_t *dirent);
|
||||||
zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
|
zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
|
||||||
void _zip_dirent_free(zip_dirent_t *);
|
void _zip_dirent_free(zip_dirent_t *);
|
||||||
void _zip_dirent_finalize(zip_dirent_t *);
|
void _zip_dirent_finalize(zip_dirent_t *);
|
||||||
|
time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de);
|
||||||
void _zip_dirent_init(zip_dirent_t *);
|
void _zip_dirent_init(zip_dirent_t *);
|
||||||
bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t);
|
bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t);
|
||||||
zip_dirent_t *_zip_dirent_new(void);
|
zip_dirent_t *_zip_dirent_new(void);
|
||||||
|
|
Loading…
Reference in New Issue