mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-17 16:38:33 +00:00
Fall back to lstat() calls on unsupported filesystems
This commit is contained in:
@@ -1300,13 +1300,17 @@ iterator walkDir*(dir: string): tuple[kind: PathComponent, path: string] {.
|
||||
var s: TStat
|
||||
y = dir / y
|
||||
var k = pcFile
|
||||
|
||||
when defined(linux) or defined(macosx):
|
||||
if x.d_type == DT_DIR: k = pcDir
|
||||
if x.d_type == DT_LNK: k = succ(k)
|
||||
else:
|
||||
if lstat(y, s) < 0'i32: break
|
||||
if S_ISDIR(s.st_mode): k = pcDir
|
||||
if S_ISLNK(s.st_mode): k = succ(k)
|
||||
if x.d_type != DT_UNKNOWN:
|
||||
if x.d_type == DT_DIR: k = pcDir
|
||||
if x.d_type == DT_LNK: k = succ(k)
|
||||
yield (k, y)
|
||||
continue
|
||||
|
||||
if lstat(y, s) < 0'i32: break
|
||||
if S_ISDIR(s.st_mode): k = pcDir
|
||||
if S_ISLNK(s.st_mode): k = succ(k)
|
||||
yield (k, y)
|
||||
discard closedir(d)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user