os.nim: allow walkDir to work on hierarchies with dangling symbolic links; refs #9034
This commit is contained in:
parent
68bc45701a
commit
c1aecb8914
1 changed files with 1 additions and 5 deletions
|
|
@ -802,20 +802,16 @@ type
|
||||||
pcDir, ## path refers to a directory
|
pcDir, ## path refers to a directory
|
||||||
pcLinkToDir ## path refers to a symbolic link to a directory
|
pcLinkToDir ## path refers to a symbolic link to a directory
|
||||||
|
|
||||||
|
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
proc getSymlinkFileKind(path: string): PathComponent =
|
proc getSymlinkFileKind(path: string): PathComponent =
|
||||||
# Helper function.
|
# Helper function.
|
||||||
var s: Stat
|
var s: Stat
|
||||||
assert(path != "")
|
assert(path != "")
|
||||||
if stat(path, s) < 0'i32:
|
if stat(path, s) == 0'i32 and S_ISDIR(s.st_mode):
|
||||||
raiseOSError(osLastError())
|
|
||||||
if S_ISDIR(s.st_mode):
|
|
||||||
result = pcLinkToDir
|
result = pcLinkToDir
|
||||||
else:
|
else:
|
||||||
result = pcLinkToFile
|
result = pcLinkToFile
|
||||||
|
|
||||||
|
|
||||||
proc staticWalkDir(dir: string; relative: bool): seq[
|
proc staticWalkDir(dir: string; relative: bool): seq[
|
||||||
tuple[kind: PathComponent, path: string]] =
|
tuple[kind: PathComponent, path: string]] =
|
||||||
discard
|
discard
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue