⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zip.htm

📁 常见的一些文件如WORD、JPG等的文件格式
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<html>

<head>
<title>file:///e:/kaifa/format/binary/zip.txt</title>
</head>

<body background="../jpg/di1.JPG">

<p align="center"><font size="6" color="#0000ff">general format of a zip file</font></p>
<div align="center"><center>

<table border="0" width="88%">
  <tr>
    <td width="100%"><pre>-------------------------------------------------
editorial note:</pre>
    <pre>this version was downloaded from the file appnote.txt
from the pkzip website on july 13, 1998.</pre>
    <pre>to obtain this file go to:  
<a href="http://www.pkware.com/download.html">http://www.pkware.com/download.html
</a>  </pre>
    <pre>then download --&gt; appnote.zip</pre>
    <pre>end of editorial note
-------------------------------------------------
</pre>
    <pre>disclaimer
----------</pre>
    <pre>although pkware will attempt to supply current and accurate
information relating to its file formats, algorithms, and the
subject programs, the possibility of error can not be eliminated.
pkware therefore expressly disclaims any warranty that the
information contained in the associated materials relating to the
subject programs and/or the format of the files created or
accessed by the subject programs and/or the algorithms used by
the subject programs, or any other matter, is current, correct or
accurate as delivered.  any risk of damage due to any possible
inaccurate information is assumed by the user of the information.
furthermore, the information relating to the subject programs
and/or the file formats created or accessed by the subject
programs and/or the algorithms used by the subject programs is
subject to change without notice.
</pre>
    <pre>general format of a zip file
----------------------------</pre>
    <pre>  files stored in arbitrary order.  large zipfiles can span multiple
  diskette media.</pre>
    <pre>  overall zipfile format:</pre>
    <pre>    [local file header + file data + data_descriptor] . . .
    [central directory] end of central directory record
</pre>
    <pre>  a.  local file header:</pre>
    <pre>        local file header signature     4 bytes  (0x04034b50)
        version needed to extract       2 bytes
        general purpose bit flag        2 bytes
        compression method              2 bytes
        last mod file time              2 bytes
        last mod file date              2 bytes
        crc-32                          4 bytes
        compressed size                 4 bytes
        uncompressed size               4 bytes
        filename length                 2 bytes
        extra field length              2 bytes</pre>
    <pre>        filename (variable size)
        extra field (variable size)
</pre>
    <pre>  b.  data descriptor:</pre>
    <pre>        crc-32                          4 bytes
        compressed size                 4 bytes
        uncompressed size               4 bytes</pre>
    <pre>      this descriptor exists only if bit 3 of the general
      purpose bit flag is set (see below).  it is byte aligned
      and immediately follows the last byte of compressed data.
      this descriptor is used only when it was not possible to
      seek in the output zip file, e.g., when the output zip file
      was standard output or a non seekable device.</pre>
    <pre>  c.  central directory structure:</pre>
    <pre>      [file header] . . .  end of central dir record</pre>
    <pre>      file header:</pre>
    <pre>        central file header signature   4 bytes  (0x02014b50)
        version made by                 2 bytes
        version needed to extract       2 bytes
        general purpose bit flag        2 bytes
        compression method              2 bytes
        last mod file time              2 bytes
        last mod file date              2 bytes
        crc-32                          4 bytes
        compressed size                 4 bytes
        uncompressed size               4 bytes
        filename length                 2 bytes
        extra field length              2 bytes
        file comment length             2 bytes
        disk number start               2 bytes
        internal file attributes        2 bytes
        external file attributes        4 bytes
        relative offset of local header 4 bytes</pre>
    <pre>        filename (variable size)
        extra field (variable size)
        file comment (variable size)</pre>
    <pre>      end of central dir record:</pre>
    <pre>        end of central dir signature    4 bytes  (0x06054b50)
        number of this disk             2 bytes
        number of the disk with the
        start of the central directory  2 bytes
        total number of entries in
        the central dir on this disk    2 bytes
        total number of entries in
        the central dir                 2 bytes
        size of the central directory   4 bytes
        offset of start of central
        directory with respect to
        the starting disk number        4 bytes
        zipfile comment length          2 bytes
        zipfile comment (variable size)
</pre>
    <pre>  d.  explanation of fields:</pre>
    <pre>      version made by (2 bytes)</pre>
    <pre>          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.  the current
          mappings are:</pre>
    <pre>          0 - ms-dos and os/2 (fat / vfat / fat32 file systems)
          1 - amiga                     2 - vax/vms
          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 thru 255 - unused</pre>
    <pre>          the lower byte indicates the version number of 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.</pre>
    <pre>      version needed to extract (2 bytes)</pre>
    <pre>          the minimum software version needed to extract the
          file, mapped as above.</pre>
    <pre>      general purpose bit flag: (2 bytes)</pre>
    <pre>          bit 0: if set, indicates that the file is encrypted.</pre>
    <pre>          (for method 6 - imploding)
          bit 1: if the compression method used was type 6,
                 imploding, then this bit, if set, indicates
                 an 8k sliding dictionary was used.  if clear,
                 then a 4k sliding dictionary was used.
          bit 2: if the compression method used was type 6,
                 imploding, then this bit, if set, indicates
                 an 3 shannon-fano trees were used to encode the
                 sliding dictionary output.  if clear, then 2
                 shannon-fano trees were used.</pre>
    <pre>          (for method 8 - deflating)
          bit 2  bit 1
            0      0    normal (-en) compression option was used.
            0      1    maximum (-ex) compression option was used.
            1      0    fast (-ef) compression option was used.
            1      1    super fast (-es) compression option was used.</pre>
    <pre>          note:  bits 1 and 2 are undefined if the compression
                 method is any other.</pre>
    <pre>          bit 3: if this bit is set, the fields crc-32, compressed size
                 and uncompressed size are set to zero in the local
                 header.  the correct values are put in the data descriptor
                 immediately following the compressed data.  (note: pkzip
                 version 2.04g for dos only recognizes this bit for method 8
                 compression, newer versions of pkzip recognize this bit
                 for any compression method.)</pre>
    <pre>          the upper three bits are reserved and used internally
          by the software when processing the zipfile.  the
          remaining bits are unused.</pre>
    <pre>      compression method: (2 bytes)</pre>
    <pre>          (see accompanying documentation for algorithm
          descriptions)</pre>
    <pre>          0 - the file is stored (no compression)
          1 - the file is shrunk
          2 - the file is reduced with compression factor 1
          3 - the file is reduced with compression factor 2
          4 - the file is reduced with compression factor 3
          5 - the file is reduced with compression factor 4
          6 - the file is imploded
          7 - reserved for tokenizing compression algorithm
          8 - the file is deflated
          9 - reserved for enhanced deflating
         10 - pkware date compression library imploding</pre>
    <pre>      date and time fields: (2 bytes each)</pre>
    <pre>          the date and time are encoded in standard ms-dos format.
          if input came from standard input, the date and time are
          those at which compression was started for this data.</pre>
    <pre>      crc-32: (4 bytes)</pre>
    <pre>          the crc-32 algorithm was generously contributed by
          david schwaderer and can be found in his excellent
          book &quot;c programmers guide to netbios&quot; published by
          howard w. sams &amp; co. inc.  the 'magic number' for
          the crc is 0xdebb20e3.  the proper crc pre and post
          conditioning is used, meaning that the crc register
          is pre-conditioned with all ones (a starting value
          of 0xffffffff) and the value is post-conditioned by
          taking the one's complement of the crc residual.
          if bit 3 of the general purpose flag is set, this
          field is set to zero in the local header and the correct
          value is put in the data descriptor and in the central
          directory.</pre>
    <pre>      compressed size: (4 bytes)
      uncompressed size: (4 bytes)</pre>
    <pre>          the size of the file compressed and uncompressed,
          respectively.  if bit 3 of the general purpose bit flag
          is set, these fields are set to zero in the local header
          and the correct values are put in the data descriptor and
          in the central directory.</pre>
    <pre>      filename length: (2 bytes)
      extra field length: (2 bytes)
      file comment length: (2 bytes)</pre>
    <pre>          the length of the filename, extra field, and comment
          fields respectively.  the combined length of any
          directory record and these three fields should not
          generally exceed 65,535 bytes.  if input came from standard
          input, the filename length is set to zero.
</pre>
    <pre>      disk number start: (2 bytes)</pre>
    <pre>          the number of the disk on which this file begins.</pre>
    <pre>      internal file attributes: (2 bytes)</pre>
    <pre>          the lowest bit of this field indicates, if set, that
          the file is apparently an ascii or text file.  if not
          set, that the file apparently contains binary data.
          the remaining bits are unused in version 1.0.</pre>
    <pre>      external file attributes: (4 bytes)</pre>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -