raiseOSError to indicate the failling of findNextFile in walkDir[Rec]
This commit is contained in:
parent
e98a2051ce
commit
495331bf20
2 changed files with 9 additions and 2 deletions
|
|
@ -672,7 +672,10 @@ 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 and getLastError() == 18: break # ERROR_NO_MORE_FILES=18
|
||||
if findNextFile(res, f) == 0'i32:
|
||||
let errCode = getLastError()
|
||||
if errCode == ERROR_NO_MORE_FILES: break
|
||||
else: raiseOSError(errCode, "findNextFile failed")
|
||||
else: # here we use glob
|
||||
var
|
||||
f: Glob
|
||||
|
|
@ -782,7 +785,10 @@ 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 and getLastError() == 18: break # ERROR_NO_MORE_FILES=18
|
||||
if findNextFile(res, f) == 0'i32:
|
||||
let errCode = getLastError()
|
||||
if errCode == ERROR_NO_MORE_FILES: break
|
||||
else: raiseOSError(errCode, "findNextFile failed")
|
||||
else:
|
||||
var d = opendir(dir)
|
||||
if d != nil:
|
||||
|
|
|
|||
|
|
@ -686,6 +686,7 @@ const
|
|||
ERROR_FILE_NOT_FOUND* = 2
|
||||
ERROR_PATH_NOT_FOUND* = 3
|
||||
ERROR_ACCESS_DENIED* = 5
|
||||
ERROR_NO_MORE_FILES* = 18
|
||||
ERROR_HANDLE_EOF* = 38
|
||||
ERROR_BAD_ARGUMENTS* = 165
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue