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

Method mkdir

tools/python-3.11.9-amd64/Lib/zipfile.py:1857–1890  ·  view source on GitHub ↗

Creates a directory inside the zip archive.

(self, zinfo_or_directory_name, mode=511)

Source from the content-addressed store, hash-verified

1855 dest.write(data)
1856
1857 def mkdir(self, zinfo_or_directory_name, mode=511):
1858 """Creates a directory inside the zip archive."""
1859 if isinstance(zinfo_or_directory_name, ZipInfo):
1860 zinfo = zinfo_or_directory_name
1861 if not zinfo.is_dir():
1862 raise ValueError("The given ZipInfo does not describe a directory")
1863 elif isinstance(zinfo_or_directory_name, str):
1864 directory_name = zinfo_or_directory_name
1865 if not directory_name.endswith("/"):
1866 directory_name += "/"
1867 zinfo = ZipInfo(directory_name)
1868 zinfo.compress_size = 0
1869 zinfo.CRC = 0
1870 zinfo.external_attr = ((0o40000 | mode) & 0xFFFF) << 16
1871 zinfo.file_size = 0
1872 zinfo.external_attr |= 0x10
1873 else:
1874 raise TypeError("Expected type str or ZipInfo")
1875
1876 with self._lock:
1877 if self._seekable:
1878 self.fp.seek(self.start_dir)
1879 zinfo.header_offset = self.fp.tell() # Start of header bytes
1880 if zinfo.compress_type == ZIP_LZMA:
1881 # Compressed data includes an end-of-stream (EOS) marker
1882 zinfo.flag_bits |= _MASK_COMPRESS_OPTION_1
1883
1884 self._writecheck(zinfo)
1885 self._didModify = True
1886
1887 self.filelist.append(zinfo)
1888 self.NameToInfo[zinfo.filename] = zinfo
1889 self.fp.write(zinfo.FileHeader(False))
1890 self.start_dir = self.fp.tell()
1891
1892 def __del__(self):
1893 """Call the "close()" method in case the user forgot."""

Callers 2

writeMethod · 0.95
_extract_memberMethod · 0.45

Calls 9

is_dirMethod · 0.95
_writecheckMethod · 0.95
FileHeaderMethod · 0.95
ZipInfoClass · 0.85
endswithMethod · 0.80
seekMethod · 0.45
tellMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected