From 7f2360d1c0ef82003af71a92cf592b3ce98d333d Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 30 Apr 2022 07:23:51 -0700 Subject: [PATCH] Distinguish between symlinks and ntfs junctions. --- voussoirkit/pathclass.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/voussoirkit/pathclass.py b/voussoirkit/pathclass.py index ad159fd..07442df 100644 --- a/voussoirkit/pathclass.py +++ b/voussoirkit/pathclass.py @@ -357,8 +357,19 @@ class Path: def is_file(self): return os.path.isfile(self) + @property + def is_junction(self): + try: + return bool(os.readlink(self)) + except (FileNotFoundError, OSError): + return False + @property def is_link(self): + return self.is_symlink or self.is_junction + + @property + def is_symlink(self): return os.path.islink(self) def join(self, subpath, **spawn_kwargs):