I myself have not used ZipArchive, but looking at the code, it can use the first version of UnzipOpenFile
without a password argument and try to call UnzipFileTo
. If this fails, you open again, but with a password and call UnzipFileTo
again. The problem is that you cannot distinguish an invalid zip file and use an invalid password.
If you really need to know if the file is encrypted, you can probably add functionally yourself (unverified code):
Add this to unzip.c
in minizip:
extern int ZEXPORT unzIsEncrypted (file) unzFile file; { return ((unz_s*)file)->encrypted; }
This is unzip.h
value:
extern int ZEXPORT unzIsEncrypted OF((unzFile file));
This is the value of ZipArchive.mm
:
- (BOOL)ZipIsEncrypted { return unzIsEncrypted(_unzFile); }
This is the value of ZipArchive.h
:
- (BOOL)ZipIsEncrypted;
And use it after calling UnzipFileTo
.
source share