Hi,
As we can seen in the sources, in the case of trying to extract a single file that is not in an archive, mz_zip_reader_save_all is supposed to return MZ_END_OF_LIST error:
int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password, minizip_opt *options)
{
[...]
/* Save all entries in zip file to destination directory */
err = mz_zip_reader_save_all(reader, destination);
if (err == MZ_END_OF_LIST && pattern != NULL)
printf("Files matching %s not found in zip file\n", pattern);
[...]
}
For example with file ZipExample.zip containing a few files:
ZipExample
├── sourceFile.txt
└── subfolder
├── empty
└── nonempty
If I extract an existing file it actually return MZ_OK (0) but it also returns MZ_OK when trying to extract a non-existing file (and we can see that the "file matching not found" log is not printed):
> ./minizip -x ZipExample.zip subfolder/nonempty
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip subfolder/nonempty
Archive ZipExample.zip
Extracting subfolder/nonempty
> echo $?
0
> ./minizip -x ZipExample.zip sourceFile.txt
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip sourceFile.txt
Archive ZipExample.zip
Extracting sourceFile.txt
> echo $?
0
> ./minizip -x ZipExample.zip there/is/no/such/file/in/archive
Minizip 2.8.3 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x ZipExample.zip there/is/no/such/file/in/archive
Archive ZipExample.zip
> echo $?
0
I'm using your lib in a C++ project then I got a easy workaround calling boost::filesystem::is_regular_file(destinationFolder / singleFile) after extract of single file but it would be nice to have mz_zip_reader_save_all actually returning proper error in this case.
Thanks.
Hi,
As we can seen in the sources, in the case of trying to extract a single file that is not in an archive, mz_zip_reader_save_all is supposed to return MZ_END_OF_LIST error:
For example with file ZipExample.zip containing a few files:
If I extract an existing file it actually return MZ_OK (0) but it also returns MZ_OK when trying to extract a non-existing file (and we can see that the "file matching not found" log is not printed):
I'm using your lib in a C++ project then I got a easy workaround calling boost::filesystem::is_regular_file(destinationFolder / singleFile) after extract of single file but it would be nice to have mz_zip_reader_save_all actually returning proper error in this case.
Thanks.