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

Method _extract_member

tools/python-3.11.9-amd64/Lib/tarfile.py:2387–2429  ·  view source on GitHub ↗

Extract the TarInfo object tarinfo to a physical file called targetpath.

(self, tarinfo, targetpath, set_attrs=True,
                        numeric_owner=False)

Source from the content-addressed store, hash-verified

2385 return None
2386
2387 def _extract_member(self, tarinfo, targetpath, set_attrs=True,
2388 numeric_owner=False):
2389 """Extract the TarInfo object tarinfo to a physical
2390 file called targetpath.
2391 """
2392 # Fetch the TarInfo object for the given name
2393 # and build the destination pathname, replacing
2394 # forward slashes to platform specific separators.
2395 targetpath = targetpath.rstrip("/")
2396 targetpath = targetpath.replace("/", os.sep)
2397
2398 # Create all upper directories.
2399 upperdirs = os.path.dirname(targetpath)
2400 if upperdirs and not os.path.exists(upperdirs):
2401 # Create directories that are not part of the archive with
2402 # default permissions.
2403 os.makedirs(upperdirs)
2404
2405 if tarinfo.islnk() or tarinfo.issym():
2406 self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname))
2407 else:
2408 self._dbg(1, tarinfo.name)
2409
2410 if tarinfo.isreg():
2411 self.makefile(tarinfo, targetpath)
2412 elif tarinfo.isdir():
2413 self.makedir(tarinfo, targetpath)
2414 elif tarinfo.isfifo():
2415 self.makefifo(tarinfo, targetpath)
2416 elif tarinfo.ischr() or tarinfo.isblk():
2417 self.makedev(tarinfo, targetpath)
2418 elif tarinfo.islnk() or tarinfo.issym():
2419 self.makelink(tarinfo, targetpath)
2420 elif tarinfo.type not in SUPPORTED_TYPES:
2421 self.makeunknown(tarinfo, targetpath)
2422 else:
2423 self.makefile(tarinfo, targetpath)
2424
2425 if set_attrs:
2426 self.chown(tarinfo, targetpath, numeric_owner)
2427 if not tarinfo.issym():
2428 self.chmod(tarinfo, targetpath)
2429 self.utime(tarinfo, targetpath)
2430
2431 #--------------------------------------------------------------------------
2432 # Below are the different file methods. They are called via

Callers 4

_extract_oneMethod · 0.95
makelinkMethod · 0.95
unpack_tarfileFunction · 0.45
untar_fileFunction · 0.45

Calls 15

_dbgMethod · 0.95
makefileMethod · 0.95
makedirMethod · 0.95
makefifoMethod · 0.95
makedevMethod · 0.95
makelinkMethod · 0.95
makeunknownMethod · 0.95
chownMethod · 0.95
chmodMethod · 0.95
utimeMethod · 0.95
islnkMethod · 0.80
issymMethod · 0.80

Tested by

no test coverage detected