MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _open_to_write

Method _open_to_write

tools/python-3.11.9-amd64/Lib/zipfile.py:1631–1671  ·  view source on GitHub ↗
(self, zinfo, force_zip64=False)

Source from the content-addressed store, hash-verified

1629 raise
1630
1631 def _open_to_write(self, zinfo, force_zip64=False):
1632 if force_zip64 and not self._allowZip64:
1633 raise ValueError(
1634 "force_zip64 is True, but allowZip64 was False when opening "
1635 "the ZIP file."
1636 )
1637 if self._writing:
1638 raise ValueError("Can't write to the ZIP file while there is "
1639 "another write handle open on it. "
1640 "Close the first handle before opening another.")
1641
1642 # Size and CRC are overwritten with correct data after processing the file
1643 zinfo.compress_size = 0
1644 zinfo.CRC = 0
1645
1646 zinfo.flag_bits = 0x00
1647 if zinfo.compress_type == ZIP_LZMA:
1648 # Compressed data includes an end-of-stream (EOS) marker
1649 zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1
1650 if not self._seekable:
1651 zinfo.flag_bits |= _MASK_USE_DATA_DESCRIPTOR
1652
1653 if not zinfo.external_attr:
1654 zinfo.external_attr = 0o600 << 16 # permissions: ?rw-------
1655
1656 # Compressed size can be larger than uncompressed size
1657 zip64 = force_zip64 or (zinfo.file_size * 1.05 > ZIP64_LIMIT)
1658 if not self._allowZip64 and zip64:
1659 raise LargeZipFile("Filesize would require ZIP64 extensions")
1660
1661 if self._seekable:
1662 self.fp.seek(self.start_dir)
1663 zinfo.header_offset = self.fp.tell()
1664
1665 self._writecheck(zinfo)
1666 self._didModify = True
1667
1668 self.fp.write(zinfo.FileHeader(zip64))
1669
1670 self._writing = True
1671 return _ZipWriteFile(self, zinfo, zip64)
1672
1673 def extract(self, member, path=None, pwd=None):
1674 """Extract a member from the archive to the current working directory,

Callers 1

openMethod · 0.95

Calls 7

_writecheckMethod · 0.95
LargeZipFileClass · 0.85
_ZipWriteFileClass · 0.85
FileHeaderMethod · 0.80
seekMethod · 0.45
tellMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected