Fix #20628 for Windows (#20667)

* Fix #20628 for Windows

* Move isRegular - !isSpecial and onlyRegular - skipSpecial

* Forgot to change it in 1 more place
This commit is contained in:
Andrey Makarov 2022-10-28 11:01:28 +03:00 • committed by GitHub
commit 779b1cc5be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 38 deletions

View file

@ -1030,8 +1030,11 @@ type
creationTime*: times.Time ## Time file was created. Not supported on all systems!
blockSize*: int ## Preferred I/O block size for this object.
## In some filesystems, this may vary from file to file.
isRegular*: bool ## Is file regular? (on Unix some "files"
## can be non-regular like FIFOs, devices)
isSpecial*: bool ## Is file special? (on Unix some "files"
## can be special=non-regular like FIFOs,
## devices); for directories `isSpecial`
## is always `false`, for symlinks it is
## the same as for the link's target.
template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
## Transforms the native file info structure into the one nim uses.
@ -1092,14 +1095,14 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
checkAndIncludeMode(S_IWOTH, fpOthersWrite)
checkAndIncludeMode(S_IXOTH, fpOthersExec)
(formalInfo.kind, formalInfo.isRegular) =
(formalInfo.kind, formalInfo.isSpecial) =
if S_ISDIR(rawInfo.st_mode):
(pcDir, true)
(pcDir, false)
elif S_ISLNK(rawInfo.st_mode):
assert(path != "") # symlinks can't occur for file handles
getSymlinkFileKind(path)
else:
(pcFile, S_ISREG(rawInfo.st_mode))
(pcFile, not S_ISREG(rawInfo.st_mode))
when defined(js):
when not declared(FileHandle):
@ -1153,7 +1156,7 @@ proc getFileInfo*(path: string, followSymlink = true): FileInfo {.noWeirdTarget.
## When `followSymlink` is true (default), symlinks are followed and the
## information retrieved is information related to the symlink's target.
## Otherwise, information on the symlink itself is retrieved (however,
## field `isRegular` is still determined from the target on Unix).
## field `isSpecial` is still determined from the target on Unix).
##
## If the information cannot be retrieved, such as when the path doesn't
## exist, or when permission restrictions prevent the program from retrieving