It seems I figured it out!

zlib adds 4 bytes of Adler32 CRC to the end of the stream. If, like  
with the first 2 bytes of the stream, we skip it, then Archive Utility  
works, and Fossil produces the same ZIP file as zip utility. Most  
likely other compression utilities just ignore Adler32 (or maybe check  
it), but Mac's ditto doesn't like it.

--- src/zip.c
+++ src/zip.c
@@ -212,18 +212,18 @@
        stream.avail_out = sizeof(zOutBuf);
        stream.next_out = (unsigned char*)zOutBuf;
        deflate(&stream, Z_FINISH);
        toOut = sizeof(zOutBuf) - stream.avail_out;
        if( toOut>skip ){
-        blob_append(&body, &zOutBuf[skip], toOut - skip);
+        blob_append(&body, &zOutBuf[skip], toOut - skip - 4); // skip  
4 bytes at the end
          skip = 0;
        }else{
          skip -= toOut;
        }
      }while( stream.avail_out==0 );
      nByte = stream.total_in;
-    nByteCompr = stream.total_out - 2;
+    nByteCompr = stream.total_out - 2 - 4;
      deflateEnd(&stream);

      /* Go back and write the header, now that we know the compressed  
file size.
      */
      z = &blob_buffer(&body)[iStart];



On 18.10.2009, at 15:43, D. Richard Hipp wrote:

>
> On Oct 18, 2009, at 6:42 AM, Dmitry Chestnykh wrote:
>
>> Hello,
>>
>> Mac OS X's built-in Archive Utility (which is the default way to
>> extract archives by double-clicking them)
>> cannot extract ZIP files generated by Fossil.
>
> http://www.fossil-scm.org/fossil/tktview?name=923a912309
>
> Curiously, the Archive Utility on OS X is the *only* unarchiver we
> know of that cannot read fossil ZIP files.  I have spent a lot of time
> trying to figure out how to do ZIP archives differently so that
> Archive Utility will understand them.  So far, no luck.
>
>
>
> D. Richard Hipp
> d...@hwaci.com
>
>
>
> _______________________________________________
> fossil-users mailing list
> fossil-users@lists.fossil-scm.org
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


--
Dmitry Chestnykh
Coding Robots

http://www.codingrobots.com
dmi...@codingrobots.com




_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to