* Implement Unix file regularity check * update std/dirs also
This commit is contained in:
parent
c1343739e1
commit
8ed2431db0
7 changed files with 107 additions and 45 deletions
|
|
@ -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`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue