home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 September / Chip_2000-09_cd1.bin / sharewar / Slunec / app / 16 / ARCHIVES.SWG / 0014_ZIP.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-03  |  5KB  |  121 lines

  1. --------A-ZIP-------------------------------
  2.  
  3. The  ZIP archives are created by the PkZIP/PkUnZIP combo produced by the
  4. PkWare  company.  The  PkZIP programs have  with  LHArc and ARJ the best
  5. compression.  The  directory  information is stored  at  the  end of the
  6. archive,  each  local  file  in the  archive  begins  with the following
  7. header; This header can be used to identify a ZIP file as such :
  8.  
  9. OFFSET              Count TYPE   Description
  10. 0000h                   4 char   ID='PK',03,04
  11. 0004h                   1 word   Version needed to extract archive
  12. 0006h                   1 word   General purpose bit field (bit mapped)
  13.                                       0 - file is encrypted
  14.                                       1 - 8K/4K sliding dictionary used
  15.                                       2 - 3/2 Shannon-Fano trees were used
  16.                                     3-4 - unused
  17.                                    5-15 - used internally by ZIP
  18.                                  Note:  Bits 1 and 2 are undefined if the
  19.                                         compression method is other than
  20.                                         type 6 (Imploding).
  21. 0008h                   1 word   Compression method (see table 0010)
  22. 000Ah                   1 dword  Original DOS file date/time
  23. 000Eh                   1 dword  32-bit CRC of file (inverse??)
  24. 0012h                   1 dword  Compressed file size
  25. 0016h                   1 dword  Uncompressed file size
  26. 001Ah                   1 word   Length of filename
  27.                                  ="LEN"
  28. 001Ch                   1 word   Length of extra field
  29.                                  ="XLN"
  30. 001Eh               "LEN" char   path/filename
  31. 001Eh               "XLN" char   extra field
  32. +"LEN"
  33.  
  34. After all the files, there comes the central directory structure.
  35. (Table 0010)
  36. PkZip compression types
  37. 0 - Stored / No compression
  38. 1 - Shrunk / LZW, 8K buffer, 9-13 bits with partial clearing
  39. 2 - Reduced-1 / Probalistic compression, lower 7 bits
  40. 3 - Reduced-2 / Probalistic compression, lower 6 bits
  41. 4 - Reduced-3 / Probalistic compression, lower 5 bits
  42. 5 - Reduced-4 / Probalistic compression, lower 4 bits
  43. 6 - Imploded / 2/3 Shanno-Fano trees, 4K/8K sliding dictionary
  44.  
  45. --- Central directory structure
  46.  
  47. The CDS is at the end of the archive and contains additional information
  48. about the files stored within the archive.
  49.  
  50. OFFSET              Count TYPE   Description
  51. 0000h                   4 char   ID='PK',01,02
  52. 0004h                   1 byte   Version made by
  53. 0005h                   1 byte   Host OS (see table 0011)
  54. 0006h                   1 byte   Minimum version needed to extract
  55. 0007h                   1 byte   Target OS
  56.                                  see above "Host OS"
  57. 0008h                   1 word   General purpose bit flag
  58.                                  see above "General purpose bit flag"
  59. 000Ah                   1 word   Compression method
  60.                                  see above "Compression method"
  61. 000Ch                   1 dword  DOS date / time of file
  62. 0010h                   1 dword  32-bit CRC of file (see table 0009)
  63. 0014h                   1 dword  Compressed size of file
  64. 0018h                   1 dword  Uncompressed size of file
  65. 001Ch                   1 word   Length of filename
  66.                                  ="LEN"
  67. 001Eh                   1 word   Length of extra field
  68.                                  ="XLN"
  69. 0020h                   1 word   Length of file comment
  70.                                  ="CMT"
  71. 0022h                   1 word   Disk number ??
  72. 0024h                   1 word   Internal file attributes (bit mapped)
  73.                                     0 - file is apparently an ASCII/binary file
  74.                                  1-15 - unused
  75. 0026h                   1 dword  External file attributes (OS dependent)
  76. 002Ah                   1 dword  Relative offset of local header from the
  77.                                  start of the first disk this file appears on
  78. 002Eh               "LEN" char   Filename / path; should not contain a drive
  79.                                  or device letter, all slashes should be forward
  80.                                  slashes '/'.
  81. 002Eh+              "XLN" char   Extra field
  82. +"LEN"
  83. 002Eh               "CMT" char   File comment
  84. +"LEN"
  85. +"XLN"
  86.  
  87. (Table 0011)
  88. PkZip Host OS table
  89. 0 - MS-DOS and OS/2 (FAT)
  90. 1 - Amiga
  91. 2 - VMS
  92. 3 - *nix
  93. 4 - VM/CMS
  94. 5 - Atari ST
  95. 6 - OS/2 1.2 extended file sys
  96. 7 - Macintosh
  97. 8-255 - unused
  98.  
  99. --- End of central directory structure
  100.  
  101. The End of Central Directory Structure header has following format :
  102.  
  103. OFFSET              Count TYPE   Description
  104. 0000h                   4 char   ID='PK',05,06
  105. 0004h                   1 word   Number of this disk
  106. 0006h                   1 word   Number of disk with start of central directory
  107. 0008h                   1 word   Total number of file/path entries on this disk
  108. 000Ah                   1 word   Total number of entries in central dir
  109. 000Ch                   1 dword  Size of central directory
  110. 0010h                   1 dword  Offset of start of central directory relative
  111.                                  to starting disk number
  112. 0014h                   1 word   Archive comment length
  113.                                  ="CML"
  114. 0016h               "CML" char   Zip file comment
  115.  
  116. EXTENSION:ZIP
  117. OCCURENCES:PC,Amiga,ST
  118. PROGRAMS:PkZIP,WinZIP
  119. REFERENCE:Technote.APP
  120.  
  121.