bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)

This commit is contained in:
Joannah Nanjekye 2019-05-04 11:27:10 -04:00 committed by Antoine Pitrou
parent f0900199d5
commit 6b5b013bcc
5 changed files with 42 additions and 0 deletions

View file

@ -411,6 +411,8 @@ class _NormalAccessor(_Accessor):
unlink = os.unlink
link_to = os.link
rmdir = os.rmdir
rename = os.rename
@ -1303,6 +1305,14 @@ class Path(PurePath):
self._raise_closed()
return self._accessor.lstat(self)
def link_to(self, target):
"""
Create a hard link pointing to a path named target.
"""
if self._closed:
self._raise_closed()
self._accessor.link_to(self, target)
def rename(self, target):
"""
Rename this path to the given path.