mattconnolly / ZipArchive

zip archive processing for Cocoa - iPhone and OS X

Home Page:http://code.google.com/p/ziparchive/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recognize protected zip file

mooseDev opened this issue · comments

How to recognize protected zip files to present textfield for user input?
Currently one only gets an general error while unzipping and it's impossible to determine that it's because the zip file was protected....

From stepping through the code, I can see that:

  1. Password protected zip files can be opened and their contents listed without a password.
  2. An error occurs only if the password is incorrect at the time the file contents are actually extracted.

The internal error code is a "Data error" which is overridden by the minizip library when it returns to ZipArchive. So there's no definitive way to know if the error is a wrong password or a corrupt zip file (what I would call a data error).

I'm not an export in Zip files or the minizip or zlib code. I made this fork to extend the Objective C front end to it. So I would check if you can list the contents and see if it fails to extract, ask the user for a password, then try again.

(Apologies for the delayed response, this fell off my radar for quite a while).