VFS: Clean up minizip usage

This commit is contained in:
Vicki Pfau 2021-02-26 00:34:18 -08:00
parent ba0b7d9157
commit d42c6e6ba5
4 changed files with 10 additions and 10 deletions

View File

@ -671,6 +671,7 @@ elseif(USE_MINIZIP)
add_definitions(-Dunztell64=unzTell64) # Bug in downstream minizip that some distros use add_definitions(-Dunztell64=unzTell64) # Bug in downstream minizip that some distros use
endif() endif()
elseif(USE_ZLIB) elseif(USE_ZLIB)
list(APPEND FEATURES MINIZIP)
list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c 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/ioapi.c
${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c

View File

@ -266,7 +266,7 @@ QString Window::getFilters() const {
#ifdef M_CORE_GBA #ifdef M_CORE_GBA
QStringList gbaFormats{ QStringList gbaFormats{
"*.gba", "*.gba",
#if defined(USE_LIBZIP) || defined(USE_ZLIB) #if defined(USE_LIBZIP) || defined(USE_MINIZIP)
"*.zip", "*.zip",
#endif #endif
#ifdef USE_LZMA #ifdef USE_LZMA
@ -288,7 +288,7 @@ QString Window::getFilters() const {
"*.gb", "*.gb",
"*.gbc", "*.gbc",
"*.sgb", "*.sgb",
#if defined(USE_LIBZIP) || defined(USE_ZLIB) #if defined(USE_LIBZIP) || defined(USE_MINIZIP)
"*.zip", "*.zip",
#endif #endif
#ifdef USE_LZMA #ifdef USE_LZMA
@ -310,7 +310,7 @@ QString Window::getFiltersArchive() const {
QStringList filters; QStringList filters;
QStringList formats{ QStringList formats{
#if defined(USE_LIBZIP) || defined(USE_ZLIB) #if defined(USE_LIBZIP) || defined(USE_MINIZIP)
"*.zip", "*.zip",
#endif #endif
#ifdef USE_LZMA #ifdef USE_LZMA

View File

@ -99,7 +99,7 @@ struct VFile* VFileOpen(const char* path, int flags) {
struct VDir* VDirOpenArchive(const char* path) { struct VDir* VDirOpenArchive(const char* path) {
struct VDir* dir = 0; struct VDir* dir = 0;
UNUSED(path); UNUSED(path);
#if defined(USE_LIBZIP) || defined(USE_ZLIB) #if defined(USE_LIBZIP) || defined(USE_MINIZIP)
if (!dir) { if (!dir) {
dir = VDirOpenZip(path, O_RDONLY); dir = VDirOpenZip(path, O_RDONLY);
} }

View File

@ -185,7 +185,7 @@ struct VDir* VDirOpenZip(const char* path, int flags) {
if ((flags & O_ACCMODE) == O_RDWR) { if ((flags & O_ACCMODE) == O_RDWR) {
return 0; // Read/write not supported return 0; // Read/write not supported
} }
if (flags & O_WRONLY) { if ((flags & O_ACCMODE) == O_WRONLY) {
z = zipOpen2(path, 0, NULL, &ops); z = zipOpen2(path, 0, NULL, &ops);
if (!z) { if (!z) {
return 0; return 0;
@ -455,7 +455,7 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) {
struct zip_file* zf = NULL; struct zip_file* zf = NULL;
struct zip_stat s = {0}; struct zip_stat s = {0};
if (mode & O_WRONLY) { if ((mode & O_ACCMODE) == O_WRONLY) {
if (!vdz->write) { if (!vdz->write) {
return 0; return 0;
} }
@ -474,7 +474,7 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) {
vfz->zf = zf; vfz->zf = zf;
vfz->z = vdz->z; vfz->z = vdz->z;
vfz->fileSize = s.size; vfz->fileSize = s.size;
if (mode & O_WRONLY) { if ((mode & O_ACCMODE) == O_WRONLY) {
vfz->name = strdup(path); vfz->name = strdup(path);
vfz->write = true; vfz->write = true;
} }
@ -696,7 +696,7 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) {
} }
unz_file_info64 info = {0}; unz_file_info64 info = {0};
if (mode & O_RDONLY) { if ((mode & O_ACCMODE) == O_RDONLY) {
if (unzLocateFile(vdz->uz, path, 0) != UNZ_OK) { if (unzLocateFile(vdz->uz, path, 0) != UNZ_OK) {
return 0; return 0;
} }
@ -709,8 +709,7 @@ struct VFile* _vdzOpenFile(struct VDir* vd, const char* path, int mode) {
if (status < 0) { if (status < 0) {
return 0; return 0;
} }
} } else {
if (mode & O_WRONLY) {
if (zipOpenNewFileInZip(vdz->z, path, NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, 3) < 0) { if (zipOpenNewFileInZip(vdz->z, path, NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, 3) < 0) {
return 0; return 0;
} }