summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linuxnamespaces/atlocation.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py
index 70f9a77..eecfed1 100644
--- a/linuxnamespaces/atlocation.py
+++ b/linuxnamespaces/atlocation.py
@@ -279,6 +279,24 @@ class AtLocation:
os.readlink(os.fspath(self.location), dir_fd=self.fd_or_none)
)
+ def rename(self, dst: "AtLocationLike") -> None:
+ """Wrapper for os.rename supplying src_dir_fd and dst_dir_fd."""
+ if self.flags != AtFlags.AT_SYMLINK_NOFOLLOW:
+ raise NotImplementedError(
+ "rename on AtLocation only supports source flag AT_SYMLINK_NOFOLLOW"
+ )
+ dst = AtLocation(dst)
+ if dst.flags != AtFlags.AT_SYMLINK_NOFOLLOW:
+ raise NotImplementedError(
+ "rename on AtLocation only supports destination flag AT_SYMLINK_NOFOLLOW"
+ )
+ os.rename(
+ self.location,
+ dst.location,
+ src_dir_fd=self.fd_or_none,
+ dst_dir_fd=dst.fd_or_none,
+ )
+
def rmdir(self) -> None:
"""Wrapper for os.rmdir supplying path and dir_fd."""
if self.flags != AtFlags.NONE: