Skip to content

file.metadata()?.len() < len in allocation code on Windows is problematic #13

@nazar-pc

Description

@nazar-pc

I have a file on Windows that has is 9512067072 bytes in size.

GetFileInformationByHandleEx also returns 9512067072 bytes in AllocationSize, however file.metadata()?.len() returns size of the file on disk, which is a bit smaller for some reason, 9512064576 to be precise, which results in file.set_len() call, specifically another SetFileInformationByHandle call with EndOfFile: len: https://github.com/rust-lang/rust/blob/1547c076bfec8abb819d6a81e1e4095d267bd5b4/library/std/src/sys/pal/windows/fs.rs#L350-L353

It would have been all fine, but that triggers one of the numerous Windows bugs. So I'm wondering why is that file.set_len() call needed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions