VFS: Clean up minizip usage
Vicki Pfau vi@endrift.com
Fri, 26 Feb 2021 00:34:18 -0800
4 files changed,
10 insertions(+),
10 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -671,6 +671,7 @@ if(NOT HAVE_UNZTELL64)
add_definitions(-Dunztell64=unzTell64) # Bug in downstream minizip that some distros use endif() elseif(USE_ZLIB) + list(APPEND FEATURES MINIZIP) list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -266,7 +266,7 @@
#ifdef M_CORE_GBA QStringList gbaFormats{ "*.gba", -#if defined(USE_LIBZIP) || defined(USE_ZLIB) +#if defined(USE_LIBZIP) || defined(USE_MINIZIP) "*.zip", #endif #ifdef USE_LZMA@@ -288,7 +288,7 @@ QStringList gbFormats{
"*.gb", "*.gbc", "*.sgb", -#if defined(USE_LIBZIP) || defined(USE_ZLIB) +#if defined(USE_LIBZIP) || defined(USE_MINIZIP) "*.zip", #endif #ifdef USE_LZMA@@ -310,7 +310,7 @@ QString Window::getFiltersArchive() const {
QStringList filters; QStringList formats{ -#if defined(USE_LIBZIP) || defined(USE_ZLIB) +#if defined(USE_LIBZIP) || defined(USE_MINIZIP) "*.zip", #endif #ifdef USE_LZMA
M
src/util/vfs.c
→
src/util/vfs.c
@@ -99,7 +99,7 @@
struct VDir* VDirOpenArchive(const char* path) { struct VDir* dir = 0; UNUSED(path); -#if defined(USE_LIBZIP) || defined(USE_ZLIB) +#if defined(USE_LIBZIP) || defined(USE_MINIZIP) if (!dir) { dir = VDirOpenZip(path, O_RDONLY); }
M
src/util/vfs/vfs-zip.c
→
src/util/vfs/vfs-zip.c
@@ -185,7 +185,7 @@
if ((flags & O_ACCMODE) == O_RDWR) { return 0; // Read/write not supported } - if (flags & O_WRONLY) { + if ((flags & O_ACCMODE) == O_WRONLY) { z = zipOpen2(path, 0, NULL, &ops); if (!z) { return 0;@@ -455,7 +455,7 @@ }
struct zip_file* zf = NULL; struct zip_stat s = {0}; - if (mode & O_WRONLY) { + if ((mode & O_ACCMODE) == O_WRONLY) { if (!vdz->write) { return 0; }@@ -474,7 +474,7 @@ struct VFileZip* vfz = calloc(1, sizeof(struct VFileZip));
vfz->zf = zf; vfz->z = vdz->z; vfz->fileSize = s.size; - if (mode & O_WRONLY) { + if ((mode & O_ACCMODE) == O_WRONLY) { vfz->name = strdup(path); vfz->write = true; }@@ -696,7 +696,7 @@ return 0;
} unz_file_info64 info = {0}; - if (mode & O_RDONLY) { + if ((mode & O_ACCMODE) == O_RDONLY) { if (unzLocateFile(vdz->uz, path, 0) != UNZ_OK) { return 0; }@@ -709,8 +709,7 @@ int status = unzGetCurrentFileInfo64(vdz->uz, &info, 0, 0, 0, 0, 0, 0);
if (status < 0) { return 0; } - } - if (mode & O_WRONLY) { + } else { if (zipOpenNewFileInZip(vdz->z, path, NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, 3) < 0) { return 0; }