Skip to content

Commit d0cfd0e

Browse files
committed
Add is_junction method to DirEntry class on Python 3.12
1 parent 39a80cf commit d0cfd0e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pyfakefs/fake_scandir.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ def stat(self, follow_symlinks=True):
114114
def __fspath__(self):
115115
return self.path
116116

117+
if sys.version_info >= (3, 12):
118+
119+
def is_junction(self) -> bool:
120+
"""Return True if this entry is a junction.
121+
Junctions are not a part of posix semantic."""
122+
if not self._filesystem.is_windows_fs:
123+
return False
124+
file_object = self._filesystem.resolve(self._abspath)
125+
return file_object.is_junction
126+
117127

118128
class ScanDirIter:
119129
"""Iterator for DirEntry objects returned from `scandir()`

0 commit comments

Comments
 (0)