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

Method makelink

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

Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link.

(self, tarinfo, targetpath)

Source from the content-addressed store, hash-verified

2499 os.makedev(tarinfo.devmajor, tarinfo.devminor))
2500
2501 def makelink(self, tarinfo, targetpath):
2502 """Make a (symbolic) link called targetpath. If it cannot be created
2503 (platform limitation), we try to make a copy of the referenced file
2504 instead of a link.
2505 """
2506 try:
2507 # For systems that support symbolic and hard links.
2508 if tarinfo.issym():
2509 if os.path.lexists(targetpath):
2510 # Avoid FileExistsError on following os.symlink.
2511 os.unlink(targetpath)
2512 os.symlink(tarinfo.linkname, targetpath)
2513 else:
2514 if os.path.exists(tarinfo._link_target):
2515 os.link(tarinfo._link_target, targetpath)
2516 else:
2517 self._extract_member(self._find_link_target(tarinfo),
2518 targetpath)
2519 except symlink_exception:
2520 try:
2521 self._extract_member(self._find_link_target(tarinfo),
2522 targetpath)
2523 except KeyError:
2524 raise ExtractError("unable to resolve link inside archive") from None
2525
2526 def chown(self, tarinfo, targetpath, numeric_owner):
2527 """Set owner of targetpath according to tarinfo. If numeric_owner

Callers 1

_extract_memberMethod · 0.95

Calls 7

_extract_memberMethod · 0.95
_find_link_targetMethod · 0.95
ExtractErrorClass · 0.85
issymMethod · 0.80
unlinkMethod · 0.45
existsMethod · 0.45
linkMethod · 0.45

Tested by

no test coverage detected