mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 11:35:38 -04:00
[minizip] Update: v4.0.9 -> v4.0.10
CMakeLists.txt: Add a missing "LINKER_LANGUAGE C". Not entirely sure when this was added, or why I missed it...
This commit is contained in:
parent
29aa2dacc9
commit
25c5aa02cc
7
extlib/minizip-ng/.gitignore
vendored
7
extlib/minizip-ng/.gitignore
vendored
@ -1,3 +1,10 @@
|
||||
# builds
|
||||
_deps/
|
||||
build/
|
||||
CMakeFiles/
|
||||
lib/
|
||||
Testing/
|
||||
third_party/
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
|
3
extlib/minizip-ng/CMakeLists.txt
vendored
3
extlib/minizip-ng/CMakeLists.txt
vendored
@ -8,7 +8,7 @@
|
||||
#cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# Library version
|
||||
set(VERSION "4.0.9")
|
||||
set(VERSION "4.0.10")
|
||||
# API version
|
||||
set(SOVERSION "4")
|
||||
|
||||
@ -721,6 +721,7 @@ set_target_properties(${MINIZIP_TARGET} PROPERTIES
|
||||
# rom-properties: Only export symbols if building shared libraries.
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
set_target_properties(${MINIZIP_TARGET} PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
DEFINE_SYMBOL "MZ_EXPORTS")
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
|
||||
|
1
extlib/minizip-ng/minizip.c
vendored
1
extlib/minizip-ng/minizip.c
vendored
@ -461,6 +461,7 @@ int32_t minizip_erase(const char *src_path, const char *target_path, int32_t arg
|
||||
if (err != MZ_OK) {
|
||||
printf("Error %" PRId32 " opening archive for reading %s\n", err, src_path);
|
||||
mz_zip_reader_delete(&reader);
|
||||
mz_zip_reader_delete(&writer);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
4
extlib/minizip-ng/mz.h
vendored
4
extlib/minizip-ng/mz.h
vendored
@ -14,8 +14,8 @@
|
||||
/***************************************************************************/
|
||||
|
||||
/* MZ_VERSION */
|
||||
#define MZ_VERSION ("4.0.9")
|
||||
#define MZ_VERSION_BUILD (0x040009)
|
||||
#define MZ_VERSION ("4.0.10")
|
||||
#define MZ_VERSION_BUILD (0x04000A)
|
||||
|
||||
/* MZ_ERROR */
|
||||
#define MZ_OK (0) /* zlib */
|
||||
|
28
extlib/minizip-ng/mz_os.c
vendored
28
extlib/minizip-ng/mz_os.c
vendored
@ -46,7 +46,7 @@ int32_t mz_path_append_slash(char *path, int32_t max_path, char slash) {
|
||||
int32_t path_len = (int32_t)strlen(path);
|
||||
if ((path_len + 2) >= max_path)
|
||||
return MZ_BUF_ERROR;
|
||||
if (path[path_len - 1] != '\\' && path[path_len - 1] != '/') {
|
||||
if (!mz_os_is_dir_separator(path[path_len - 1])) {
|
||||
path[path_len] = slash;
|
||||
path[path_len + 1] = 0;
|
||||
}
|
||||
@ -56,7 +56,7 @@ int32_t mz_path_append_slash(char *path, int32_t max_path, char slash) {
|
||||
int32_t mz_path_remove_slash(char *path) {
|
||||
int32_t path_len = (int32_t)strlen(path);
|
||||
while (path_len > 0) {
|
||||
if (path[path_len - 1] == '\\' || path[path_len - 1] == '/')
|
||||
if (mz_os_is_dir_separator(path[path_len - 1]))
|
||||
path[path_len - 1] = 0;
|
||||
else
|
||||
break;
|
||||
@ -68,7 +68,7 @@ int32_t mz_path_remove_slash(char *path) {
|
||||
|
||||
int32_t mz_path_has_slash(const char *path) {
|
||||
int32_t path_len = (int32_t)strlen(path);
|
||||
if (path_len > 0 && path[path_len - 1] != '\\' && path[path_len - 1] != '/')
|
||||
if (path_len > 0 && !mz_os_is_dir_separator(path[path_len - 1]))
|
||||
return MZ_EXIST_ERROR;
|
||||
return MZ_OK;
|
||||
}
|
||||
@ -77,7 +77,7 @@ int32_t mz_path_convert_slashes(char *path, char slash) {
|
||||
int32_t i = 0;
|
||||
|
||||
for (i = 0; i < (int32_t)strlen(path); i += 1) {
|
||||
if (path[i] == '\\' || path[i] == '/')
|
||||
if (mz_os_is_dir_separator(path[i]))
|
||||
path[i] = slash;
|
||||
}
|
||||
return MZ_OK;
|
||||
@ -136,12 +136,12 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) {
|
||||
|
||||
while (*source != 0 && max_output > 1) {
|
||||
check = source;
|
||||
if (*check == '\\' || *check == '/')
|
||||
if (mz_os_is_dir_separator(*check))
|
||||
check += 1;
|
||||
|
||||
if (source == path || target == output || check != source) {
|
||||
/* Skip double paths */
|
||||
if (*check == '\\' || *check == '/') {
|
||||
if (mz_os_is_dir_separator(*check)) {
|
||||
source += 1;
|
||||
continue;
|
||||
}
|
||||
@ -158,7 +158,7 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) {
|
||||
continue;
|
||||
}
|
||||
/* Remove . if not at end of string */
|
||||
else if (*check == '\\' || *check == '/') {
|
||||
else if (mz_os_is_dir_separator(*check)) {
|
||||
source += (check - source);
|
||||
/* Skip slash if at beginning of string */
|
||||
if (target == output && *source != 0)
|
||||
@ -168,14 +168,14 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) {
|
||||
/* Go to parent directory .. */
|
||||
else if (*check == '.') {
|
||||
check += 1;
|
||||
if (*check == 0 || (*check == '\\' || *check == '/')) {
|
||||
if (*check == 0 || mz_os_is_dir_separator(*check)) {
|
||||
source += (check - source);
|
||||
|
||||
/* Search backwards for previous slash or the start of the output string */
|
||||
if (target != output) {
|
||||
target -= 1;
|
||||
do {
|
||||
if (target == output || *target == '\\' || *target == '/')
|
||||
if (target == output || mz_os_is_dir_separator(*target))
|
||||
break;
|
||||
|
||||
target -= 1;
|
||||
@ -185,7 +185,7 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) {
|
||||
|
||||
if ((target == output) && *source != 0)
|
||||
source += 1;
|
||||
if ((*target == '\\' || *target == '/') && *source == 0)
|
||||
if (mz_os_is_dir_separator(*target) && *source == 0)
|
||||
target += 1;
|
||||
|
||||
*target = 0;
|
||||
@ -219,7 +219,7 @@ int32_t mz_path_remove_filename(char *path) {
|
||||
path_ptr = path + strlen(path) - 1;
|
||||
|
||||
while (path_ptr > path) {
|
||||
if ((*path_ptr == '/') || (*path_ptr == '\\')) {
|
||||
if (mz_os_is_dir_separator(*path_ptr)) {
|
||||
*path_ptr = 0;
|
||||
break;
|
||||
}
|
||||
@ -242,7 +242,7 @@ int32_t mz_path_remove_extension(char *path) {
|
||||
path_ptr = path + strlen(path) - 1;
|
||||
|
||||
while (path_ptr > path) {
|
||||
if ((*path_ptr == '/') || (*path_ptr == '\\'))
|
||||
if (mz_os_is_dir_separator(*path_ptr))
|
||||
break;
|
||||
if (*path_ptr == '.') {
|
||||
*path_ptr = 0;
|
||||
@ -267,7 +267,7 @@ int32_t mz_path_get_filename(const char *path, const char **filename) {
|
||||
*filename = NULL;
|
||||
|
||||
for (match = path; *match != 0; match += 1) {
|
||||
if ((*match == '\\') || (*match == '/'))
|
||||
if (mz_os_is_dir_separator(*match))
|
||||
*filename = match + 1;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ int32_t mz_dir_make(const char *path) {
|
||||
if (err != MZ_OK) {
|
||||
match = current_dir + 1;
|
||||
while (1) {
|
||||
while (*match != 0 && *match != '\\' && *match != '/')
|
||||
while (*match != 0 && !mz_os_is_dir_separator(*match))
|
||||
match += 1;
|
||||
hold = *match;
|
||||
*match = 0;
|
||||
|
3
extlib/minizip-ng/mz_os.h
vendored
3
extlib/minizip-ng/mz_os.h
vendored
@ -150,6 +150,9 @@ struct dirent *mz_os_read_dir(DIR *dir);
|
||||
int32_t mz_os_close_dir(DIR *dir);
|
||||
/* Closes a directory that has been opened for listing */
|
||||
|
||||
int32_t mz_os_is_dir_separator(const char c);
|
||||
/* Checks to see if character is a directory separator */
|
||||
|
||||
int32_t mz_os_is_dir(const char *path);
|
||||
/* Checks to see if path is a directory */
|
||||
|
||||
|
37
extlib/minizip-ng/mz_os_posix.c
vendored
37
extlib/minizip-ng/mz_os_posix.c
vendored
@ -37,6 +37,10 @@
|
||||
# include <stdlib.h> /* arc4random_buf */
|
||||
#endif
|
||||
|
||||
#ifndef MZ_PRESERVE_NATIVE_STRUCTURE
|
||||
# define MZ_PRESERVE_NATIVE_STRUCTURE 1
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if defined(HAVE_ICONV)
|
||||
@ -49,21 +53,17 @@ char *mz_os_utf8_string_create(const char *string, int32_t encoding) {
|
||||
char *string_utf8 = NULL;
|
||||
char *string_utf8_ptr = NULL;
|
||||
|
||||
if (!string)
|
||||
if (!string || encoding <= 0)
|
||||
return NULL;
|
||||
|
||||
if (encoding == MZ_ENCODING_CODEPAGE_437)
|
||||
from_encoding = "CP437";
|
||||
else if (encoding == MZ_ENCODING_CODEPAGE_932)
|
||||
from_encoding = "CP932";
|
||||
else if (encoding == MZ_ENCODING_CODEPAGE_936)
|
||||
from_encoding = "CP936";
|
||||
else if (encoding == MZ_ENCODING_CODEPAGE_950)
|
||||
from_encoding = "CP950";
|
||||
else if (encoding == MZ_ENCODING_UTF8)
|
||||
if (encoding == MZ_ENCODING_UTF8)
|
||||
from_encoding = "UTF-8";
|
||||
else
|
||||
return NULL;
|
||||
else {
|
||||
/// up to CP2147483647
|
||||
char string_encoding[13];
|
||||
snprintf(string_encoding, sizeof(string_encoding), "CP%03" PRId32, encoding);
|
||||
from_encoding = string_encoding;
|
||||
}
|
||||
|
||||
cd = iconv_open("UTF-8", from_encoding);
|
||||
if (cd == (iconv_t)-1)
|
||||
@ -89,7 +89,6 @@ char *mz_os_utf8_string_create(const char *string, int32_t encoding) {
|
||||
}
|
||||
#else
|
||||
char *mz_os_utf8_string_create(const char *string, int32_t encoding) {
|
||||
MZ_UNUSED(encoding);
|
||||
return strdup(string);
|
||||
}
|
||||
#endif
|
||||
@ -290,6 +289,18 @@ int32_t mz_os_close_dir(DIR *dir) {
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_os_is_dir_separator(const char c) {
|
||||
#if MZ_PRESERVE_NATIVE_STRUCTURE
|
||||
// While not strictly adhering to 4.4.17.1,
|
||||
// this preserves UNIX filesystem structure.
|
||||
return c == '/';
|
||||
#else
|
||||
// While strictly adhering to 4.4.17.1,
|
||||
// this corrupts UNIX filesystem structure (a filename with a '\\' will become a folder + a file).
|
||||
return c == '\\' || c == '/';
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t mz_os_is_dir(const char *path) {
|
||||
struct stat path_stat;
|
||||
|
||||
|
4
extlib/minizip-ng/mz_os_win32.c
vendored
4
extlib/minizip-ng/mz_os_win32.c
vendored
@ -440,6 +440,10 @@ int32_t mz_os_close_dir(DIR *dir) {
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t mz_os_is_dir_separator(const char c) {
|
||||
return c == '\\' || c == '/';
|
||||
}
|
||||
|
||||
int32_t mz_os_is_dir(const char *path) {
|
||||
wchar_t *path_wide = NULL;
|
||||
uint32_t attribs = 0;
|
||||
|
9
extlib/minizip-ng/mz_zip.c
vendored
9
extlib/minizip-ng/mz_zip.c
vendored
@ -17,6 +17,7 @@
|
||||
|
||||
#include "mz.h"
|
||||
#include "mz_crypt.h"
|
||||
#include "mz_os.h"
|
||||
#include "mz_strm.h"
|
||||
#ifdef HAVE_BZIP2
|
||||
# include "mz_strm_bzip.h"
|
||||
@ -1566,8 +1567,7 @@ int32_t mz_zip_set_comment(void *handle, const char *comment) {
|
||||
zip->comment = (char *)calloc(comment_size + 1, sizeof(char));
|
||||
if (!zip->comment)
|
||||
return MZ_MEM_ERROR;
|
||||
// using memcpy() instead of strncpy() to avoid -Werror=stringop-truncation
|
||||
memcpy(zip->comment, comment, comment_size + 1);
|
||||
strncpy(zip->comment, comment, comment_size);
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
@ -1988,7 +1988,7 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int1
|
||||
if (mz_zip_attrib_is_dir(zip->file_info.external_fa, zip->file_info.version_madeby) == MZ_OK)
|
||||
is_dir = 1;
|
||||
|
||||
if (!is_dir) {
|
||||
if (!raw && !is_dir) {
|
||||
if (zip->data_descriptor)
|
||||
zip->file_info.flag |= MZ_ZIP_FLAG_DATA_DESCRIPTOR;
|
||||
if (password)
|
||||
@ -2296,8 +2296,7 @@ int32_t mz_zip_entry_is_dir(void *handle) {
|
||||
|
||||
filename_length = (int32_t)strlen(zip->file_info.filename);
|
||||
if (filename_length > 0) {
|
||||
if ((zip->file_info.filename[filename_length - 1] == '/') ||
|
||||
(zip->file_info.filename[filename_length - 1] == '\\'))
|
||||
if (mz_os_is_dir_separator(zip->file_info.filename[filename_length - 1]))
|
||||
return MZ_OK;
|
||||
}
|
||||
return MZ_EXIST_ERROR;
|
||||
|
31
extlib/minizip-ng/mz_zip_rw.c
vendored
31
extlib/minizip-ng/mz_zip_rw.c
vendored
@ -39,7 +39,7 @@ typedef struct mz_zip_reader_s {
|
||||
uint16_t hash_algorithm;
|
||||
uint16_t hash_digest_size;
|
||||
mz_zip_file *file_info;
|
||||
const char *pattern;
|
||||
char *pattern;
|
||||
uint8_t pattern_ignore_case;
|
||||
const char *password;
|
||||
void *overwrite_userdata;
|
||||
@ -230,6 +230,11 @@ int32_t mz_zip_reader_close(void *handle) {
|
||||
mz_stream_delete(&reader->mem_stream);
|
||||
}
|
||||
|
||||
if (reader->pattern) {
|
||||
free(reader->pattern);
|
||||
reader->pattern = NULL;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -654,18 +659,18 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) {
|
||||
if (!reader->file_info || !path)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
/* Convert to forward slashes for unix which doesn't like backslashes */
|
||||
pathwfs = (char *)strdup(path);
|
||||
if (!pathwfs)
|
||||
return MZ_MEM_ERROR;
|
||||
mz_path_convert_slashes(pathwfs, MZ_PATH_SLASH_UNIX);
|
||||
|
||||
if (reader->entry_cb)
|
||||
reader->entry_cb(handle, reader->entry_userdata, reader->file_info, pathwfs);
|
||||
|
||||
directory = (char *)strdup(pathwfs);
|
||||
if (!directory)
|
||||
return MZ_MEM_ERROR;
|
||||
if (!directory) {
|
||||
err = MZ_MEM_ERROR;
|
||||
goto save_cleanup;
|
||||
}
|
||||
mz_path_remove_filename(directory);
|
||||
|
||||
/* If it is a directory entry then create a directory instead of writing file */
|
||||
@ -905,7 +910,19 @@ save_all_cleanup:
|
||||
|
||||
void mz_zip_reader_set_pattern(void *handle, const char *pattern, uint8_t ignore_case) {
|
||||
mz_zip_reader *reader = (mz_zip_reader *)handle;
|
||||
reader->pattern = pattern;
|
||||
if (!reader)
|
||||
return;
|
||||
free(reader->pattern);
|
||||
reader->pattern = NULL;
|
||||
if (pattern) {
|
||||
/* pattern can be NULL */
|
||||
int32_t pattern_size = (int32_t)strlen(pattern);
|
||||
reader->pattern = (char *)calloc(pattern_size + 1, sizeof(char));
|
||||
if (!reader->pattern)
|
||||
/* Reference: `mz_zip_set_comment`, should return MZ_MEM_ERROR */
|
||||
return;
|
||||
strncpy(reader->pattern, pattern, pattern_size);
|
||||
}
|
||||
reader->pattern_ignore_case = ignore_case;
|
||||
}
|
||||
|
||||
@ -1642,7 +1659,7 @@ int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_
|
||||
char full_path[1024];
|
||||
char path_dir[1024];
|
||||
|
||||
if (strrchr(path, '*')) {
|
||||
if (strrchr(path, '*') && mz_os_file_exists(path) != MZ_OK) {
|
||||
strncpy(path_dir, path, sizeof(path_dir) - 1);
|
||||
path_dir[sizeof(path_dir) - 1] = 0;
|
||||
mz_path_remove_filename(path_dir);
|
||||
|
Loading…
Reference in New Issue
Block a user