Lines Matching refs:zinfo
518 zinfo = cls(arcname, date_time)
519 zinfo.external_attr = (st.st_mode & 0xFFFF) << 16 # Unix attributes
521 zinfo.file_size = 0
522 zinfo.external_attr |= 0x10 # MS-DOS directory flag
524 zinfo.file_size = st.st_size
526 return zinfo
1072 def __init__(self, zf, zinfo, zip64): argument
1073 self._zinfo = zinfo
1076 self._compressor = _get_compressor(zinfo.compress_type,
1077 zinfo._compresslevel)
1372 for zinfo in self.filelist:
1373 date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6]
1374 print("%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size),
1380 for zinfo in self.filelist:
1384 with self.open(zinfo.filename, "r") as f:
1388 return zinfo.filename
1460 zinfo = name
1462 zinfo = ZipInfo(name)
1463 zinfo.compress_type = self.compression
1464 zinfo._compresslevel = self.compresslevel
1467 zinfo = self.getinfo(name)
1470 return self._open_to_write(zinfo, force_zip64=force_zip64)
1479 zef_file = _SharedFile(self.fp, zinfo.header_offset,
1494 if zinfo.flag_bits & 0x20:
1498 if zinfo.flag_bits & 0x40:
1502 if zinfo.flag_bits & 0x800:
1508 if fname_str != zinfo.orig_filename:
1511 % (zinfo.orig_filename, fname))
1514 is_encrypted = zinfo.flag_bits & 0x1
1531 if zinfo.flag_bits & 0x8:
1533 check_byte = (zinfo._raw_time >> 8) & 0xff
1536 check_byte = (zinfo.CRC >> 24) & 0xff
1540 return ZipExtFile(zef_file, mode, zinfo, zd, True)
1545 def _open_to_write(self, zinfo, force_zip64=False): argument
1557 if not hasattr(zinfo, 'file_size'):
1558 zinfo.file_size = 0
1559 zinfo.compress_size = 0
1560 zinfo.CRC = 0
1562 zinfo.flag_bits = 0x00
1563 if zinfo.compress_type == ZIP_LZMA:
1565 zinfo.flag_bits |= 0x02
1567 zinfo.flag_bits |= 0x08
1569 if not zinfo.external_attr:
1570 zinfo.external_attr = 0o600 << 16 # permissions: ?rw-------
1574 (force_zip64 or zinfo.file_size * 1.05 > ZIP64_LIMIT)
1578 zinfo.header_offset = self.fp.tell()
1580 self._writecheck(zinfo)
1583 self.fp.write(zinfo.FileHeader(zip64))
1586 return _ZipWriteFile(self, zinfo, zip64)
1675 def _writecheck(self, zinfo): argument
1677 if zinfo.filename in self.NameToInfo:
1679 warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3)
1685 _check_compression(zinfo.compress_type)
1690 elif zinfo.file_size > ZIP64_LIMIT:
1692 elif zinfo.header_offset > ZIP64_LIMIT:
1710 zinfo = ZipInfo.from_file(filename, arcname)
1712 if zinfo.is_dir():
1713 zinfo.compress_size = 0
1714 zinfo.CRC = 0
1717 zinfo.compress_type = compress_type
1719 zinfo.compress_type = self.compression
1722 zinfo._compresslevel = compresslevel
1724 zinfo._compresslevel = self.compresslevel
1726 if zinfo.is_dir():
1730 zinfo.header_offset = self.fp.tell() # Start of header bytes
1731 if zinfo.compress_type == ZIP_LZMA:
1733 zinfo.flag_bits |= 0x02
1735 self._writecheck(zinfo)
1738 self.filelist.append(zinfo)
1739 self.NameToInfo[zinfo.filename] = zinfo
1740 self.fp.write(zinfo.FileHeader(False))
1743 with open(filename, "rb") as src, self.open(zinfo, 'w') as dest:
1756 zinfo = ZipInfo(filename=zinfo_or_arcname,
1758 zinfo.compress_type = self.compression
1759 zinfo._compresslevel = self.compresslevel
1760 if zinfo.filename[-1] == '/':
1761 zinfo.external_attr = 0o40775 << 16 # drwxrwxr-x
1762 zinfo.external_attr |= 0x10 # MS-DOS directory flag
1764 zinfo.external_attr = 0o600 << 16 # ?rw-------
1766 zinfo = zinfo_or_arcname
1777 zinfo.compress_type = compress_type
1780 zinfo._compresslevel = compresslevel
1782 zinfo.file_size = len(data) # Uncompressed size
1784 with self.open(zinfo, mode='w') as dest:
1814 for zinfo in self.filelist: # write central directory
1815 dt = zinfo.date_time
1819 if zinfo.file_size > ZIP64_LIMIT \
1820 or zinfo.compress_size > ZIP64_LIMIT:
1821 extra.append(zinfo.file_size)
1822 extra.append(zinfo.compress_size)
1826 file_size = zinfo.file_size
1827 compress_size = zinfo.compress_size
1829 if zinfo.header_offset > ZIP64_LIMIT:
1830 extra.append(zinfo.header_offset)
1833 header_offset = zinfo.header_offset
1835 extra_data = zinfo.extra
1846 if zinfo.compress_type == ZIP_BZIP2:
1848 elif zinfo.compress_type == ZIP_LZMA:
1851 extract_version = max(min_version, zinfo.extract_version)
1852 create_version = max(min_version, zinfo.create_version)
1854 filename, flag_bits = zinfo._encodeFilenameFlags()
1857 zinfo.create_system, extract_version, zinfo.reserved,
1858 flag_bits, zinfo.compress_type, dostime, dosdate,
1859 zinfo.CRC, compress_size, file_size,
1860 len(filename), len(extra_data), len(zinfo.comment),
1861 0, zinfo.internal_attr, zinfo.external_attr,
1865 zinfo.create_system, extract_version, zinfo.reserved,
1866 zinfo.flag_bits, zinfo.compress_type, dostime, dosdate,
1867 zinfo.CRC, compress_size, file_size,
1868 len(zinfo.filename), len(extra_data), len(zinfo.comment),
1869 0, zinfo.internal_attr, zinfo.external_attr,
1875 self.fp.write(zinfo.comment)