Distinguish between symlinks and ntfs junctions.

master
voussoir 2022-04-30 07:23:51 -07:00
parent cb84774231
commit 7f2360d1c0
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 11 additions and 0 deletions

View File

@ -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):