home *** CD-ROM | disk | FTP | other *** search
/ The Companion for Windows / thecompanionforwindows1993.iso / zip110 / appnote.txt < prev    next >
Text File  |  1990-03-14  |  26KB  |  753 lines

  1.  
  2. Disclaimer
  3. ----------
  4.  
  5. Although PKWARE will attempt to supply current and accurate
  6. information relating to its file formats, algorithms, and the
  7. subject programs, the possibility of error can not be eliminated.
  8. PKWARE therefore expressly disclaims any warranty that the
  9. information contained in the associated materials relating to the
  10. subject programs and/or the format of the files created or
  11. accessed by the subject programs and/or the algorithms used by
  12. the subject programs, or any other matter, is current, correct or
  13. accurate as delivered.  Any risk of damage due to any possible
  14. inaccurate information is assumed by the user of the information.
  15. Furthermore, the information relating to the subject programs
  16. and/or the file formats created or accessed by the subject
  17. programs and/or the algorithms used by the subject programs is
  18. subject to change without notice.
  19.  
  20.  
  21. General Format of a ZIP file
  22. ----------------------------
  23.  
  24.   Files stored in arbitrary order.  Large zipfiles can span multiple
  25.   diskette media.
  26.  
  27.   Overall zipfile format:
  28.  
  29.     [local file header+file data] . . .
  30.     [central directory] end of central directory record
  31.  
  32.  
  33.   A.  Local file header:
  34.  
  35.     local file header signature    4 bytes  (0x04034b50)
  36.     version needed to extract    2 bytes
  37.     general purpose bit flag    2 bytes
  38.     compression method        2 bytes
  39.     last mod file time         2 bytes
  40.     last mod file date        2 bytes
  41.     crc-32               4 bytes
  42.     compressed size            4 bytes
  43.     uncompressed size        4 bytes
  44.     filename length            2 bytes
  45.     extra field length        2 bytes
  46.  
  47.     filename (variable size)
  48.     extra field (variable size)
  49.  
  50.  
  51.   B.  Central directory structure:
  52.  
  53.       [file header] . . .  end of central dir record
  54.  
  55.       File header:
  56.  
  57.     central file header signature    4 bytes  (0x02014b50)
  58.     version made by            2 bytes
  59.     version needed to extract    2 bytes
  60.     general purpose bit flag    2 bytes
  61.     compression method        2 bytes
  62.     last mod file time         2 bytes
  63.     last mod file date        2 bytes
  64.     crc-32               4 bytes
  65.     compressed size            4 bytes
  66.     uncompressed size        4 bytes
  67.     filename length            2 bytes
  68.     extra field length        2 bytes
  69.     file comment length        2 bytes
  70.     disk number start        2 bytes
  71.     internal file attributes    2 bytes
  72.     external file attributes    4 bytes
  73.     relative offset of local header    4 bytes
  74.  
  75.     filename (variable size)
  76.     extra field (variable size)
  77.     file comment (variable size)
  78.  
  79.       End of central dir record:
  80.  
  81.     end of central dir signature    4 bytes  (0x06054b50)
  82.     number of this disk        2 bytes
  83.     number of the disk with the
  84.     start of the central directory    2 bytes
  85.     total number of entries in
  86.     the central dir on this disk    2 bytes
  87.     total number of entries in
  88.     the central dir            2 bytes
  89.     size of the central directory   4 bytes
  90.     offset of start of central
  91.     directory with respect to
  92.     the starting disk number    4 bytes
  93.     zipfile comment length        2 bytes
  94.     zipfile comment (variable size)
  95.  
  96.  
  97.  
  98.  
  99.   C.  Explanation of fields:
  100.  
  101.       version made by
  102.  
  103.       The upper byte indicates the host system (OS) for the
  104.       file.  Software can use this information to determine
  105.       the line record format for text files etc.  The current
  106.       mappings are:
  107.  
  108.       0 - MS-DOS and OS/2 (F.A.T. file systems)
  109.       1 - Amiga            2 - VMS
  110.       3 - *nix            4 - VM/CMS
  111.       5 - Atari ST                  6 - OS/2 H.P.F.S.
  112.       7 - Macintosh            8 - Z-System
  113.       9 - CP/M            10 thru 255 - unused
  114.  
  115.       The lower byte indicates the version number of the
  116.       software used to encode the file.  The value/10
  117.       indicates the major version number, and the value
  118.       mod 10 is the minor version number.
  119.  
  120.       version needed to extract
  121.  
  122.       The minimum software version needed to extract the
  123.       file, mapped as above.
  124.  
  125.       general purpose bit flag:
  126.  
  127.           bit 0: If set, indicates that the file is encrypted.
  128.           bit 1: If the compression method used was type 6,
  129.          Imploding, then this bit, if set, indicates
  130.          an 8K sliding dictionary was used.  If clear,
  131.          then a 4K sliding dictionary was used.
  132.           bit 2: If the compression method used was type 6,
  133.          Imploding, then this bit, if set, indicates
  134.          an 3 Shannon-Fano trees were used to encode the
  135.          sliding dictionary output.  If clear, then 2
  136.          Shannon-Fano trees were used.
  137.       Note:  Bits 1 and 2 are undefined if the compression
  138.          method is other than type 6 (Imploding).
  139.  
  140.           The upper three bits are reserved and used internally
  141.       by the software when processing the zipfile.  The
  142.       remaining bits are unused in version 1.0.
  143.  
  144.       compression method:
  145.  
  146.       (see accompanying documentation for algorithm
  147.       descriptions)
  148.  
  149.       0 - The file is stored (no compression)
  150.       1 - The file is Shrunk
  151.       2 - The file is Reduced with compression factor 1
  152.       3 - The file is Reduced with compression factor 2
  153.       4 - The file is Reduced with compression factor 3
  154.       5 - The file is Reduced with compression factor 4
  155.           6 - The file is Imploded
  156.  
  157.       date and time fields:
  158.  
  159.       The date and time are encoded in standard MS-DOS
  160.       format.
  161.  
  162.       CRC-32:
  163.  
  164.       The CRC-32 algorithm was generously contributed by
  165.       David Schwaderer and can be found in his excellent
  166.       book "C Programmers Guide to NetBIOS" published by
  167.       Howard W. Sams & Co. Inc.  The 'magic number' for
  168.       the CRC is 0xdebb20e3.  The proper CRC pre and post
  169.       conditioning is used, meaning that the CRC register
  170.       is pre-conditioned with all ones (a starting value
  171.       of 0xffffffff) and the value is post-conditioned by
  172.       taking the one's complement of the CRC residual.
  173.     
  174.       compressed size:
  175.       uncompressed size:
  176.  
  177.       The size of the file compressed and uncompressed,
  178.       respectively.
  179.  
  180.       filename length:
  181.       extra field length:
  182.       file comment length:
  183.  
  184.       The length of the filename, extra field, and comment
  185.       fields respectively.  The combined length of any
  186.       directory record and these three fields should not
  187.       generally exceed 65,535 bytes.
  188.  
  189.       disk number start:
  190.  
  191.       The number of the disk on which this file begins.
  192.  
  193.       internal file attributes:
  194.  
  195.       The lowest bit of this field indicates, if set, that
  196.       the file is apparently an ASCII or text file.  If not
  197.       set, that the file apparently contains binary data.
  198.       The remaining bits are unused in version 1.0.
  199.  
  200.       external file attributes:
  201.  
  202.       The mapping of the external attributes is
  203.       host-system dependent (see 'version made by').  For
  204.       MS-DOS, the low order byte is the MS-DOS directory
  205.       attribute byte.
  206.  
  207.       relative offset of local header:
  208.  
  209.       This is the offset from the start of the first disk on
  210.       which this file appears, to where the local header should
  211.       be found.
  212.  
  213.       filename:
  214.  
  215.       The name of the file, with optional relative path.
  216.       The path stored should not contain a drive or
  217.       device letter, or a leading slash.  All slashes
  218.       should be forward slashes '/' as opposed to
  219.       backwards slashes '\' for compatibility with Amiga
  220.       and Unix file systems etc.
  221.  
  222.       extra field:
  223.  
  224.       This is for future expansion.  If additional information
  225.       needs to be stored in the future, it should be stored
  226.       here.  Earlier versions of the software can then safely
  227.       skip this file, and find the next file or header.  This
  228.       field will be 0 length in version 1.0.
  229.  
  230.       In order to allow different programs and different types 
  231.       of information to be stored in the 'extra' field in .ZIP 
  232.       files, the following structure should be used for all 
  233.       programs storing data in this field:
  234.  
  235.       header1+data1 + header2+data2 . . .
  236.  
  237.       Each header should consist of:
  238.  
  239.         Header ID - 2 bytes
  240.         Data Size - 2 bytes
  241.  
  242.       Note: all fields stored in Intel low-byte/high-byte order.
  243.  
  244.       The Header ID field indicates the type of data that is in 
  245.       the following data block.
  246.       
  247.       Header ID's of 0 thru 31 are reserved for use by PKWARE.  
  248.       The remaining ID's can be used by third party vendors for 
  249.       proprietary usage.
  250.  
  251.       The Data Size field indicates the size of the following 
  252.       data block. Programs can use this value to skip to the 
  253.       next header block, passing over any data blocks that are 
  254.       not of interes