diff options
author | def <dennis@felsin9.de> | 2015-02-24 23:31:31 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-02-24 23:31:31 +0100 |
commit | 34d87c105cdb667b40df6c7c3c953d0c9cd6180a (patch) | |
tree | 462650b95ccf697757d4612cf7e6f0116464a116 /lib | |
parent | 18dd5e196508818f47fcf069479089ccb46f7eea (diff) | |
download | Nim-34d87c105cdb667b40df6c7c3c953d0c9cd6180a.tar.gz |
Fall back to lstat() calls on unsupported filesystems
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/os.nim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 23e01a7d4..f668e756d 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -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) |