summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/os.nim16
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)