Skip to content

Commit

Permalink
template hygiene (#15240)
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek authored Aug 29, 2020
1 parent 13e659c commit b5424b8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3080,14 +3080,15 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
formalInfo.permissions = {fpUserExec, fpUserRead, fpGroupExec,
fpGroupRead, fpOthersExec, fpOthersRead}
else:
result.permissions = {fpUserExec..fpOthersRead}
formalInfo.permissions = {fpUserExec..fpOthersRead}

# Retrieve basic file kind
result.kind = pcFile
if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0'i32:
formalInfo.kind = pcDir
else:
formalInfo.kind = pcFile
if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32:
formalInfo.kind = succ(result.kind)
formalInfo.kind = succ(formalInfo.kind)

else:
template checkAndIncludeMode(rawMode, formalMode: untyped) =
Expand All @@ -3100,7 +3101,7 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
formalInfo.lastWriteTime = rawInfo.st_mtim.toTime
formalInfo.creationTime = rawInfo.st_ctim.toTime

result.permissions = {}
formalInfo.permissions = {}
checkAndIncludeMode(S_IRUSR, fpUserRead)
checkAndIncludeMode(S_IWUSR, fpUserWrite)
checkAndIncludeMode(S_IXUSR, fpUserExec)
Expand All @@ -3113,12 +3114,14 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
checkAndIncludeMode(S_IWOTH, fpOthersWrite)
checkAndIncludeMode(S_IXOTH, fpOthersExec)

formalInfo.kind = pcFile
if S_ISDIR(rawInfo.st_mode):
formalInfo.kind = pcDir
elif S_ISLNK(rawInfo.st_mode):
assert(path != "") # symlinks can't occur for file handles
formalInfo.kind = getSymlinkFileKind(path)
formalInfo.kind =
if S_ISDIR(rawInfo.st_mode):
pcDir
elif S_ISLNK(rawInfo.st_mode):
assert(path != "") # symlinks can't occur for file handles
getSymlinkFileKind(path)
else:
pcFile

when defined(js):
when not declared(FileHandle):
Expand Down

0 comments on commit b5424b8

Please sign in to comment.