Skip to content

Commit c9c145d

Browse files
VarriountPMunch
authored andcommitted
Merge file size fields correctly on Windows (nim-lang#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 nim-lang#19135 * Update os.nim
1 parent bf88830 commit c9c145d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/pure/os.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,11 @@ template rawToFormalFileInfo(rawInfo, path, formalInfo): untyped =
32553255
## 'rawInfo' is either a 'BY_HANDLE_FILE_INFORMATION' structure on Windows,
32563256
## or a 'Stat' structure on posix
32573257
when defined(windows):
3258-
template merge(a, b): untyped = a or (b shl 32)
3258+
template merge(a, b): untyped =
3259+
int64(
3260+
(uint64(cast[uint32](a))) or
3261+
(uint64(cast[uint32](b)) shl 32)
3262+
)
32593263
formalInfo.id.device = rawInfo.dwVolumeSerialNumber
32603264
formalInfo.id.file = merge(rawInfo.nFileIndexLow, rawInfo.nFileIndexHigh)
32613265
formalInfo.size = merge(rawInfo.nFileSizeLow, rawInfo.nFileSizeHigh)

0 commit comments

Comments
 (0)