Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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