Fall back to lstat() calls on unsupported filesystems

This commit is contained in:
def
2015-02-24 23:31:31 +01:00
parent 18dd5e1965
commit 34d87c105c

View File

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