Files
rust/library/std
Jacob Pratt 4e1b5867f5 Rollup merge of #159439 - PaulDance:patches/fix-win7-dir-remove-file, r=ChrisDenton
Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`

The `test_dir_remove_file` test currently fails under Windows 7 on:

```
thread 'fs::tests::test_dir_remove_file' (2028) panicked at library/std/src/fs/tests.rs:2590:5:
dir.remove_file("foo.txt") failed with: The parameter is incorrect. (os error 87)
```

Looking into it, this is because the `FILE_DISPOSITION_INFO_EX` variant of the `SetFileInformationByHandle` API is used while it is only available starting from Windows 10 1607. However, `FILE_DISPOSITION_INFO` is still available since Vista.

This is therefore fixed by introducing a fallback to the latter API if the former fails. This is achieved by re-using some logic that is already available through `File::delete` and that does exactly this.

cc rust-lang/rust#120426 @roblabla @the8472 @ChrisDenton @RalfJung

@rustbot label A-io T-libs O-Windows-7
2026-07-26 00:21:52 -04:00
..
2026-06-30 09:01:03 +00:00
2026-07-22 10:49:07 +08:00