diff options
author | Araq <rumpf_a@web.de> | 2015-08-16 13:33:05 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-08-16 13:41:28 +0200 |
commit | d81578cb9b4776356d610e2329ffc7f3323d13db (patch) | |
tree | 87aeaaf28d624fe8d66ceed610d02e3ed578616f /lib | |
parent | cc934a1a1bdbe896d1d9d2f2f1a6acccb249ed33 (diff) | |
download | Nim-d81578cb9b4776356d610e2329ffc7f3323d13db.tar.gz |
workaround windows 'findNextFile' bug
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/os.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 48d255dca..c2c28c2b1 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1244,7 +1244,14 @@ iterator walkFiles*(pattern: string): string {.tags: [ReadDirEffect].} = while true: if not skipFindData(f) and (f.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) == 0'i32: - yield splitFile(pattern).dir / extractFilename(getFilename(f)) + # Windows bug/gotcha: 't*.nim' matches 'tfoo.nims' -.- so we check + # that the file extensions have the same length ... + let ff = getFilename(f) + let dotPos = searchExtPos(pattern) + let idx = ff.len - pattern.len + dotPos + 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 findClose(res) else: # here we use glob |