From f9b0cf016effb397e32c413c9b0384eb6ee3b4a9 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 11 Mar 2024 21:47:51 +0100 Subject: add method AtLocation.is_absolute This is similar to pathlib.Path.is_absolute. --- linuxnamespaces/atlocation.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'linuxnamespaces') diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py index eecfed1..2bd3f51 100644 --- a/linuxnamespaces/atlocation.py +++ b/linuxnamespaces/atlocation.py @@ -217,6 +217,13 @@ class AtLocation: follow_symlinks=follow_symlinks, ) + def is_absolute(self) -> bool: + """Report whether the location is absolute or not. Not that any + location with an a valid filedescriptor is considered absolute as it is + not dependent on the working directory. + """ + return self.fd >= 0 or pathlib.Path(self.location).is_absolute() + def link(self, dst: "AtLocationLike") -> None: """Wrapper for os.link supplying src_dir_fd, dst_dir_fd and follow_symlinks. -- cgit v1.2.3