Fall back to lstat() calls on unsupported filesystems

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

View file

@ -1300,13 +1300,17 @@ iterator walkDir*(dir: string): tuple[kind: PathComponent, path: string] {.
var s: TStat var s: TStat
y = dir / y y = dir / y
var k = pcFile var k = pcFile
when defined(linux) or defined(macosx): when defined(linux) or defined(macosx):
if x.d_type == DT_DIR: k = pcDir if x.d_type != DT_UNKNOWN:
if x.d_type == DT_LNK: k = succ(k) if x.d_type == DT_DIR: k = pcDir
else: if x.d_type == DT_LNK: k = succ(k)
if lstat(y, s) < 0'i32: break yield (k, y)
if S_ISDIR(s.st_mode): k = pcDir continue
if S_ISLNK(s.st_mode): k = succ(k)
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) yield (k, y)
discard closedir(d) discard closedir(d)