mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)
This commit is contained in:
parent
f0900199d5
commit
6b5b013bcc
5 changed files with 42 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue