| author | |
| committer | |
| log | 1816bb4ab050f46504a2f1e827e9d74f8d253101 |
| tree | 5d671fc099d1aeb3fc1b06e18beb5037ccec4b20 |
| parent | e265dc61e651d67bbfb3be675ff132df865902ef |
Usage of FILE_RENAME_IGNORE_READONLY_ATTRIBUTE or
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE for posix semantics require
win10_rs5 instead of win10_rs1 necessary for posix semantics. Keep it as simple
as possible, since it is reasonable to expect users being able to update
win10_rs5 or use non-posix semantics instead.
Closes #17049.2 files changed, 9 insertions(+), 2 deletions(-)
lib/std/os.zig+7-1| ... | ... | @@ -2631,7 +2631,13 @@ pub fn renameatW( |
| 2631 | 2631 | |
| 2632 | 2632 | var need_fallback = true; |
| 2633 | 2633 | var rc: windows.NTSTATUS = undefined; |
| 2634 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs1)) { | |
| 2634 | // FILE_RENAME_INFORMATION_EX and FILE_RENAME_POSIX_SEMANTICS require >= win10_rs1, | |
| 2635 | // but FILE_RENAME_IGNORE_READONLY_ATTRIBUTE requires >= win10_rs5. We check >= rs5 here | |
| 2636 | // so that we only use POSIX_SEMANTICS when we know IGNORE_READONLY_ATTRIBUTE will also be | |
| 2637 | // supported in order to avoid either (1) using a redundant call that we can know in advance will return | |
| 2638 | // STATUS_NOT_SUPPORTED or (2) only setting IGNORE_READONLY_ATTRIBUTE when >= rs5 | |
| 2639 | // and therefore having different behavior when the Windows version is >= rs1 but < rs5. | |
| 2640 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs5)) { | |
| 2635 | 2641 | const struct_buf_len = @sizeOf(windows.FILE_RENAME_INFORMATION_EX) + (MAX_PATH_BYTES - 1); |
| 2636 | 2642 | var rename_info_buf: [struct_buf_len]u8 align(@alignOf(windows.FILE_RENAME_INFORMATION_EX)) = undefined; |
| 2637 | 2643 | const struct_len = @sizeOf(windows.FILE_RENAME_INFORMATION_EX) - 1 + new_path_w.len * 2; |
lib/std/os/windows.zig+2-1| ... | ... | @@ -992,8 +992,9 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil |
| 992 | 992 | // are only supported on NTFS filesystems, so the version check on its own is only a partial solution. To support non-NTFS filesystems |
| 993 | 993 | // like FAT32, we need to fallback to FileDispositionInformation if the usage of FileDispositionInformationEx gives |
| 994 | 994 | // us INVALID_PARAMETER. |
| 995 | // The same reasoning for win10_rs5 as in os.renameatW() applies (FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE requires >= win10_rs5). | |
| 995 | 996 | var need_fallback = true; |
| 996 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs1)) { | |
| 997 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs5)) { | |
| 997 | 998 | // Deletion with posix semantics if the filesystem supports it. |
| 998 | 999 | var info = FILE_DISPOSITION_INFORMATION_EX{ |
| 999 | 1000 | .Flags = FILE_DISPOSITION_DELETE | |