mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Added back unzLocateFile variant for minizip 1.2 with MZ_COMPAT_VERSION.
This commit is contained in:
parent
fbd8443122
commit
6c5f265a55
38
mz_compat.c
38
mz_compat.c
@ -1099,6 +1099,7 @@ int unzGoToNextFile(unzFile file) {
|
||||
return err;
|
||||
}
|
||||
|
||||
#if MZ_COMPAT_VERSION < 110
|
||||
#ifdef WIN32
|
||||
# define UNZ_DEFAULT_IGNORE_CASE 1
|
||||
#else
|
||||
@ -1141,6 +1142,43 @@ int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_c
|
||||
compat->entry_index = preserve_index;
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
int unzLocateFile(unzFile file, const char* filename, unzFileNameComparer filename_compare_func) {
|
||||
mz_compat* compat = (mz_compat*)file;
|
||||
mz_zip_file* file_info = NULL;
|
||||
uint64_t preserve_index = 0;
|
||||
int32_t err = MZ_OK;
|
||||
int32_t result = 0;
|
||||
|
||||
if (!compat)
|
||||
return UNZ_PARAMERROR;
|
||||
|
||||
preserve_index = compat->entry_index;
|
||||
|
||||
err = mz_zip_goto_first_entry(compat->handle);
|
||||
while (err == MZ_OK) {
|
||||
err = mz_zip_entry_get_info(compat->handle, &file_info);
|
||||
if (err != MZ_OK)
|
||||
break;
|
||||
|
||||
if ((intptr_t)filename_compare_func > 2) {
|
||||
result = filename_compare_func(file, filename, file_info->filename);
|
||||
}
|
||||
else {
|
||||
int32_t case_sensitive = (int32_t)(intptr_t)filename_compare_func;
|
||||
result = mz_path_compare_wc(filename, file_info->filename, !case_sensitive);
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
return MZ_OK;
|
||||
|
||||
err = mz_zip_goto_next_entry(compat->handle);
|
||||
}
|
||||
|
||||
compat->entry_index = preserve_index;
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
@ -308,12 +308,16 @@ typedef struct unz_file_info_s {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if MZ_COMPAT_VERSION < 110
|
||||
/* Possible values:
|
||||
0 - Uses OS default, e.g. Windows ignores case.
|
||||
1 - Is case sensitive.
|
||||
>= 2 - Ignore case.
|
||||
*/
|
||||
typedef int unzFileNameCase;
|
||||
#else
|
||||
typedef int (*unzFileNameComparer)(unzFile file, const char* filename1, const char* filename2);
|
||||
#endif
|
||||
typedef int (*unzIteratorFunction)(unzFile file);
|
||||
typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename,
|
||||
uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment,
|
||||
@ -354,7 +358,11 @@ ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_in
|
||||
|
||||
ZEXPORT int unzGoToFirstFile(unzFile file);
|
||||
ZEXPORT int unzGoToNextFile(unzFile file);
|
||||
#if MZ_COMPAT_VERSION < 110
|
||||
ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_case);
|
||||
#else
|
||||
ZEXPORT int unzLocateFile(unzFile file, const char* filename, unzFileNameComparer filename_compare_func);
|
||||
#endif
|
||||
|
||||
ZEXPORT int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user