diff options
author | Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> | 2019-05-04 11:27:10 -0400 |
---|---|---|
committer | Antoine Pitrou <antoine@python.org> | 2019-05-04 17:27:10 +0200 |
commit | 6b5b013bcc22a27d6231c2796882e44ddb42be67 (patch) | |
tree | 3542414369283f216bb25a02f99ddea67180519e /Lib/pathlib.py | |
parent | f0900199d53df97bd792ac5a1678f8c477f117bb (diff) | |
download | cpython-git-6b5b013bcc22a27d6231c2796882e44ddb42be67.tar.gz |
bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 911b774b56..1ba98b19e8 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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. |