diff options
author | alaviss <alaviss@users.noreply.github.com> | 2018-12-21 20:12:48 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-12-21 14:12:48 +0100 |
commit | b6257f3f212036216fb4aeb521a3d120222b237c (patch) | |
tree | 37738cd9a0ed5f080c1b0e607c9a0f209c5cc84e /lib/pure | |
parent | 52e36a19a902edcc533c0e0ffd0eff8c83158fef (diff) | |
download | Nim-b6257f3f212036216fb4aeb521a3d120222b237c.tar.gz |
os.walkDir: correctly evaluate paths when relative = true (#10057) [backport]
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/os.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 2919b39f0..330d2d6b8 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1512,8 +1512,9 @@ iterator walkDir*(dir: string; relative=false): tuple[kind: PathComponent, path: var y = $x.d_name.cstring if y != "." and y != "..": var s: Stat + let path = dir / y if not relative: - y = dir / y + y = path var k = pcFile when defined(linux) or defined(macosx) or @@ -1521,16 +1522,16 @@ iterator walkDir*(dir: string; relative=false): tuple[kind: PathComponent, path: if x.d_type != DT_UNKNOWN: if x.d_type == DT_DIR: k = pcDir if x.d_type == DT_LNK: - if dirExists(y): k = pcLinkToDir + if dirExists(path): k = pcLinkToDir else: k = pcLinkToFile yield (k, y) continue - if lstat(y, s) < 0'i32: break + if lstat(path, s) < 0'i32: break if S_ISDIR(s.st_mode): k = pcDir elif S_ISLNK(s.st_mode): - k = getSymlinkFileKind(y) + k = getSymlinkFileKind(path) yield (k, y) iterator walkDirRec*(dir: string, |