diff options
Diffstat (limited to 'lib/std/private/oscommon.nim')
-rw-r--r-- | lib/std/private/oscommon.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/std/private/oscommon.nim b/lib/std/private/oscommon.nim index dd66d137e..dbed1ba96 100644 --- a/lib/std/private/oscommon.nim +++ b/lib/std/private/oscommon.nim @@ -77,14 +77,17 @@ type when defined(posix) and not weirdTarget: - proc getSymlinkFileKind*(path: string): PathComponent = + proc getSymlinkFileKind*(path: string): + tuple[pc: PathComponent, isRegular: bool] = # Helper function. var s: Stat assert(path != "") - if stat(path, s) == 0'i32 and S_ISDIR(s.st_mode): - result = pcLinkToDir - else: - result = pcLinkToFile + result = (pcLinkToFile, true) + if stat(path, s) == 0'i32: + if S_ISDIR(s.st_mode): + result = (pcLinkToDir, true) + elif not S_ISREG(s.st_mode): + result = (pcLinkToFile, false) proc tryMoveFSObject*(source, dest: string, isDir: bool): bool {.noWeirdTarget.} = ## Moves a file (or directory if `isDir` is true) from `source` to `dest`. |