Bug
In library/std/src/sys/fs/windows.rs:600, the UWP path uses info.AllocationSize from FILE_STANDARD_INFO instead of info.EndOfFile.
AllocationSize is the disk space allocated for the file (rounded up to filesystem cluster size). On a 4K-cluster NTFS volume, a 1-byte file reports metadata().len() as 4096. The non-UWP path correctly uses nFileSizeLow/nFileSizeHigh which return the actual file size.
Fix
Change info.AllocationSize to info.EndOfFile.
Bug
In
library/std/src/sys/fs/windows.rs:600, the UWP path usesinfo.AllocationSizefromFILE_STANDARD_INFOinstead ofinfo.EndOfFile.AllocationSizeis the disk space allocated for the file (rounded up to filesystem cluster size). On a 4K-cluster NTFS volume, a 1-byte file reportsmetadata().len()as 4096. The non-UWP path correctly usesnFileSizeLow/nFileSizeHighwhich return the actual file size.Fix
Change
info.AllocationSizetoinfo.EndOfFile.