Skip to content

Windows UWP file_attr returns AllocationSize instead of actual file size #397

@SebTardif

Description

@SebTardif

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fsFilesystem operationsI-wrongWrong result or data corruptionO-windowsWindows-specificP-mediumMedium impact: affects specific usage patterns

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions