Skip to content

Commit 85ee4ec

Browse files
committed
fix(py): with for os.ScandirIterator; add follow_symlinks for DirEntry.stat
1 parent fa4d969 commit 85ee4ec

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pylib/Lib/os_impl/posix_like/scandirImpl.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ iterator items*[T](scandirIter: ScandirIterator[T]): DirEntry[T] =
4444
for i in scandirIter.iter():
4545
yield i
4646
47+
template enter*(self: ScandirIterator): ScandirIterator = self
48+
template exit*(self: ScandirIterator; args: varargs[untyped]) =
49+
bind close
50+
self.close()
51+
4752
using self: DirEntry
4853
4954
when InJs:
@@ -64,10 +69,11 @@ else:
6469
func repr*(self): string =
6570
"<DirEntry " & self.name.repr & '>'
6671
67-
func stat*(self): stat_result =
72+
proc stat*(self; follow_symlinks=true): stat_result =
73+
static: assert not compiles(self.dir_fd) # currently impl assumes no dir_fd
6874
if self.stat_res != nil:
6975
return self.stat_res[]
70-
result = stat(self.path)
76+
result = stat(self.path, follow_symlinks=follow_symlinks)
7177
new self.stat_res
7278
self.stat_res[] = result
7379

0 commit comments

Comments
 (0)