Files
rust/library/std/src
Matthias Krüger 51df98ddb0 Rollup merge of #131072 - Fulgen301:windows-rename-posix-semantics, r=ChrisDenton
Win: Use POSIX rename semantics for `std::fs::rename` if available

Windows 10 1601 introduced `FileRenameInfoEx` as well as `FILE_RENAME_FLAG_POSIX_SEMANTICS`, allowing for atomic renaming and renaming if the target file is has already been opened with `FILE_SHARE_DELETE`, in which case the file gets renamed on disk while the open file handle still refers to the old file, just like in POSIX. This resolves #123985, where atomic renaming proved difficult to impossible due to race conditions.

If `FileRenameInfoEx` isn't available due to missing support from the underlying filesystem or missing OS support, the renaming is retried with `FileRenameInfo`, which matches the behavior of `MoveFileEx`.

This PR also manually replicates parts of `MoveFileEx`'s internal logic, as reverse-engineered from the disassembly: If the source file is a reparse point and said reparse point is a mount point, the mount point itself gets renamed; otherwise the reparse point is resolved and the result renamed.

Notes:
- Currently, the `win7` target doesn't bother with `FileRenameInfoEx` at all; it's probably desirable to remove that special casing and try `FileRenameInfoEx` anyway if it doesn't exist, in case the binary is run on newer OS versions.

Fixes #123985
2024-12-21 22:16:02 +01:00
..
2023-12-10 10:56:22 +08:00
2024-12-03 07:52:01 +01:00
2024-07-29 08:26:52 +10:00
2024-11-27 12:10:21 +00:00
2024-11-02 11:27:14 +01:00
2024-12-21 01:26:47 +00:00
2024-01-11 11:30:12 -05:00
2024-11-12 15:08:41 -06:00
2024-07-29 08:26:52 +10:00
2024-12-05 00:26:13 +00:00
2024-08-01 15:38:51 -04:00
2024-04-08 11:57:17 +00:00
2024-12-13 11:53:01 +01:00
2024-12-21 01:26:47 +00:00
2024-10-22 20:18:11 -04:00