I'm struggling to compute the correct value for version made by in adm-zip.
The Zip Spec is unclear in my opinion how to find the binary or int value to set an option (e.g. Option 3 Unix) to the depending 2 Bytes in the central header.
The docs from adm-zip for the header setting does not help at all.
Mapping from the zip spec (4.4.2):
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
I have found one possible solution by setting the entry.header.made property to 788.
(entry.header as any).made = 788;
(This value was only found by importing a zip created by another zip util.)
Can anyone explain how to compute this value 788 starting from the desired option 3?
Or how to compute this value for another option e.g. 10 - Windows NTFS?
Short description:
According to the specification the upper byte represents the OS which created the ZIP file. The lower byte is the version of the used ZIP specification.
In your example:
788 =
0x0314OS which created the ZIP file:
0x03(Upper Byte): UNIXZIP specification version:
0x14(Lower Byte): Version 2.00x14 / 10= 2 (Major version number)0x14 % 10= 0 (Minor version number)For Windows NTFS, the correct "version made by" value should be:
0x0A14= 25800x0A(Upper Byte): Windows NTFS (Win32)0x14(Lower Byte): Version 2.0Extract from adm-zip source:
Here you can see, that the version 2.0 (
0x14) from the ZIP specification is used and there is a simple OR with the left shifted OS which created the ZIP file.UPDATE:
I wrote a few simple JavaScript example functions which returns the right value for
verMadeand which returns the OS, major and minor version number fromverMade.Set version:
Usage:
Argument
os:Put her the OS string. Currently possible values are
dos(MS-DOS),win32(Windows NTFS),darwin(OS X) and the default isunix.Argument
spec_major:Put here the major version number from the used ZIP specification.
Argument
spec_minor:Put here the minor version number from the used ZIP specification.
Return:
Returns
verMade.Get OS:
Usage:
Argument
verMade:Put here the
verMadevalue.Return:
Returns the OS as string.
Get major version number (ZIP specification):
Usage:
Argument
verMade:Put here the
verMadevalue.Return:
Returns the major version from the used ZIP specification.
Get minor version number (ZIP specification):
Usage:
Argument
verMade:Put here the
verMadevalue.Return:
Returns the minor version from the used ZIP specification.