HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Problem between the Mac 'Archive Utility' and Zend zip code

Problem between the Mac 'Archive Utility' and Zend zip code This is a very technical blog post for programmers, and nothing to do with ocPortal. Hopefully people experiencing the same problem I did will find this when they search.

The Mac produces an error:
Unable to unarchive "xxx.zip" into "xxx".
(Error 1 - Operation not permitted.)
when unzipping any file archived via the zip file class originally posted as a Zend tutorial.

If you look in the Mac console you'll see an error:
ditto: Couldn't read pkzip signature.

It'd be nice if the UI gave that error rather than "Operation not permitted", but I digress.

The problem is apparently the fault of the example code the Zend consultant gave, as it's not meeting the ZIP file specification properly and Apple's app can't cope (just about any other unzip app will work though, including on the command line). The Zend code has these lines (I'm talking about the set immediately after $fr .= $zdata;):

Code

$fr .= pack("V",$crc);
$fr .= pack("V",$c_len);
$fr .= pack("V",$unc_len);
which are to output the so called "Data descriptor". However, the 3rd bit of the 'General purpose bit flag' was not set in the code so Apple got confused when it met the extraneous data descriptor.

To solve the problem just strip the 3 lines I identified.

I'm going to point the article author to this blog post. I think my interpretation of the spec is correctly in Apple's favour, and the fix certainly works. At first I thought it was Apple's fault but I then realised the General purpose bit flag was actually blank and thus not indicating the existence of the Data descriptor section.

View all

Trackbacks

There have been no trackbacks yet

Edited