mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
check ERROR_NO_MORE_FILES to prevent walkDir[Rec] to quit prematurely
This commit is contained in:
@@ -672,7 +672,7 @@ template walkCommon(pattern: string, filter) =
|
||||
if dotPos < 0 or idx >= ff.len or ff[idx] == '.' or
|
||||
pattern[dotPos+1] == '*':
|
||||
yield splitFile(pattern).dir / extractFilename(ff)
|
||||
if findNextFile(res, f) == 0'i32: break
|
||||
if findNextFile(res, f) == 0'i32 and getLastError() == 18: break # ERROR_NO_MORE_FILES=18
|
||||
else: # here we use glob
|
||||
var
|
||||
f: Glob
|
||||
@@ -782,7 +782,7 @@ iterator walkDir*(dir: string; relative=false): tuple[kind: PathComponent, path:
|
||||
let xx = if relative: extractFilename(getFilename(f))
|
||||
else: dir / extractFilename(getFilename(f))
|
||||
yield (k, xx)
|
||||
if findNextFile(h, f) == 0'i32: break
|
||||
if findNextFile(h, f) == 0'i32 and getLastError() == 18: break # ERROR_NO_MORE_FILES=18
|
||||
else:
|
||||
var d = opendir(dir)
|
||||
if d != nil:
|
||||
|
||||
Reference in New Issue
Block a user