This link tiene más información que cualquier otra cosa que he podido encontrar en la red. Incluso la fuente zip no tiene nada. Copiando la sección relevante para la posteridad. Este parche no se trata realmente de documentar este formato, lo que demuestra cuán patética (es decir, inexistente) es la documentación actual.
# external_attr is 4 bytes in size. The high order two
# bytes represent UNIX permission and file type bits,
# while the low order two contain MS-DOS FAT file
# attributes, most notably bit 4 marking directories.
if node.isfile:
zipinfo.compress_type = ZIP_DEFLATED
zipinfo.external_attr = 0644 << 16L # permissions -r-wr--r--
data = node.get_content().read()
properties = node.get_properties()
if 'svn:special' in properties and \
data.startswith('link '):
data = data[5:]
zipinfo.external_attr |= 0120000 << 16L # symlink file type
zipinfo.compress_type = ZIP_STORED
if 'svn:executable' in properties:
zipinfo.external_attr |= 0755 << 16L # -rwxr-xr-x
zipfile.writestr(zipinfo, data)
elif node.isdir and path:
if not zipinfo.filename.endswith('/'):
zipinfo.filename += '/'
zipinfo.compress_type = ZIP_STORED
zipinfo.external_attr = 040755 << 16L # permissions drwxr-xr-x
zipinfo.external_attr |= 0x10 # MS-DOS directory flag
zipfile.writestr(zipinfo, '')
Además, this link tiene lo siguiente. Aquí, el byte de orden inferior presumiblemente significa el byte más a la derecha (el más bajo) de los cuatro bytes. Así que este es para MS-DOS y, presumiblemente, se puede dejar en cero. atributos
archivo externo: (4 bytes)
The mapping of the external attributes is
host-system dependent (see 'version made by'). For
MS-DOS, the low order byte is the MS-DOS directory
attribute byte. If input came from standard input, this
field is set to zero.
Además, el archivo fuente de Unix/unix.c en las fuentes de programa de compresión de InfoZip, descargado de Debian's archives tiene la siguiente en los comentarios.
/* lower-middle external-attribute byte (unused until now):
* high bit => (have GMT mod/acc times) >>> NO LONGER USED! <<<
* second-high bit => have Unix UID/GID info
* NOTE: The high bit was NEVER used in any official Info-ZIP release,
* but its future use should be avoided (if possible), since it
* was used as "GMT mod/acc times local extra field" flags in Zip beta
* versions 2.0j up to 2.0v, for about 1.5 years.
*/
Tomando todo esto en conjunto, parece que solo se utiliza realmente el segundo byte más alto, al menos para Unix.
EDIT: Pregunté sobre el aspecto Unix de esto en Unix.SX, en la pregunta "The zip format's external file attribute". Parece que tengo un par de cosas mal. Específicamente, los dos bytes superiores se usan para Unix.
Esto sería más legible si el buffer, nombre y bytes se definieron en el ejemplo. –
seguro, agregó algunas definiciones de ejemplo. – Tom
Para Python 3, debe escribir esto '0o777 << 16' –