Skip to content

fix(windows): use EndOfFile instead of AllocationSize for UWP file size#402

Open
SebTardif wants to merge 1 commit into
mainfrom
fix-f200
Open

fix(windows): use EndOfFile instead of AllocationSize for UWP file size#402
SebTardif wants to merge 1 commit into
mainfrom
fix-f200

Conversation

@SebTardif

Copy link
Copy Markdown
Owner

Fixes #397

On UWP targets, File::metadata().len() returned the disk allocation size instead of the actual file size.

On UWP targets, File::metadata().len() returns AllocationSize from
FILE_STANDARD_INFO, which is the disk space allocated (rounded to
cluster size), not the actual file size. A 1-byte file on a 4K-cluster
NTFS volume would report len() as 4096. Use EndOfFile instead, which
is the actual end-of-file position matching the non-UWP path.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif SebTardif added bug Something isn't working I-wrong Wrong result or data corruption P-medium Medium impact: affects specific usage patterns A-libs Standard library O-windows Windows-specific labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-libs Standard library bug Something isn't working I-wrong Wrong result or data corruption O-windows Windows-specific P-medium Medium impact: affects specific usage patterns

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows UWP file_attr returns AllocationSize instead of actual file size

1 participant