zlibminizip

How to correctly set versionMadeBy field for zipOpenNewFileInZip4 in minizip (Zlib library)


I need my application to properly zip files in Windows, UNIX, Mac etc. Earlier I was on Zlib 1.2.3 and now migrating to 1.3.1. I have API calls to zipOpenNewFileInZip4 which has a new field versionMadeBy. Has anyone used this successfully in an application across different platforms smoothly. If so could you please guide me on the same

Went through https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

version made by (2 bytes)

    4.4.2.1 The upper byte indicates the compatibility of the file
    attribute information.  If the external file attributes 
    are compatible with MS-DOS and can be read by PKZIP for 
    DOS version 2.04g then this value will be zero.  If these 
    attributes are not compatible, then this value will 
    identify the host system on which the attributes are 
    compatible.  Software can use this information to determine
    the line record format for text files etc.  

    4.4.2.2 The current mappings are:

     0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)
     1 - Amiga                     2 - OpenVMS
     3 - UNIX                      4 - VM/CMS
     5 - Atari ST                  6 - OS/2 H.P.F.S.
     7 - Macintosh                 8 - Z-System
     9 - CP/M                     10 - Windows NTFS
    11 - MVS (OS/390 - Z/OS)      12 - VSE
    13 - Acorn Risc               14 - VFAT
    15 - alternate MVS            16 - BeOS
    17 - Tandem                   18 - OS/400
    19 - OS X (Darwin)            20 thru 255 - unused

    4.4.2.3 The lower byte indicates the ZIP specification version 
    (the version of this document) supported by the software 
    used to encode the file.  The value/10 indicates the major 
    version number, and the value mod 10 is the minor version 
    number.  

I am not completely sure if I understood this documentation


Solution

  • Set the high byte to the operating system that the external attributes (external_fa) come from. If attributes are zero, then just set the operating system to zero.

    The low byte would be the originating version of PKZip. I don't think anything ever looks at it, but Section 4.4.3 has a list of PKZip features as a function of the version number. You would likely set it to 45.