summary refs log tree commit diff stats
path: root/lib/pure/os.nim
diff options
context:
space:
mode:
authorClay Sweetser <Varriount@users.noreply.github.com>2021-11-12 22:51:43 -0500
committerGitHub <noreply@github.com>2021-11-12 22:51:43 -0500
commit0a1049881eaa08cb7d10194d9b446d8a9ca52122 (patch)
treeb645de2881072e8c178ac16b59b48938a0c25e2e /lib/pure/os.nim
parentc6fc3b2eae5aac68480a787b7fa3b81e3748bc2f (diff)
downloadNim-0a1049881eaa08cb7d10194d9b446d8a9ca52122.tar.gz
Merge file size fields correctly on Windows (#19141)
* Merge file size fields correctly on Windows

Merge file size fields correctly on Windows

- Merge the two 32-bit file size fields from `BY_HANDLE_FILE_INFORMATION` correctly in `rawToFormalFileInfo`.
- Fixes #19135

* Update os.nim
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r--lib/pure/os.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim
index 513e09b48..9b08fe2e1 100644
--- a/lib/pure/os.nim
+++ b/lib/pure/os.nim
@@ -3255,7 +3255,11 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
   ## 'rawInfo' is either a 'BY_HANDLE_FILE_INFORMATION' structure on Windows,
   ## or a 'Stat' structure on posix
   when defined(windows):
-    template merge(a, b): untyped = a or (b shl 32)
+    template merge(a, b): untyped =
+      int64(
+        (uint64(cast[uint32](a))) or
+        (uint64(cast[uint32](b)) shl 32)
+       )
     formalInfo.id.device = rawInfo.dwVolumeSerialNumber
     formalInfo.id.file = merge(rawInfo.nFileIndexLow, rawInfo.nFileIndexHigh)
     formalInfo.size = merge(rawInfo.nFileSizeLow, rawInfo.nFileSizeHigh)