Distinguish between symlinks and ntfs junctions.

This commit is contained in:
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

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