authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-15 15:47:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-15 15:47:42-04:00
loge36978906214cb8c3dba693a073914394a90d0d8
treecf3da4a709773dae9c5a23ba0aafa65bde3bb4a9
parent6c2b23593b97aef6f375bd7d81beeaf0f66f5682

fix std.os.renameatW

Ask for DELETE access when opening the source file. Additionally, when the source and dest dir are the same, pass null for RootDirectory.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/os.zig+2-2
......@@ -1650,7 +1650,7 @@ pub fn renameatW(
16501650 new_path_w: [*:0]const u16,
16511651 ReplaceIfExists: windows.BOOLEAN,
16521652) RenameError!void {
1653 const access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE;
1653 const access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE | windows.DELETE;
16541654 const src_fd = try windows.OpenFileW(old_dir_fd, old_path, null, access_mask, windows.FILE_OPEN);
16551655 defer windows.CloseHandle(src_fd);
16561656
......@@ -1664,7 +1664,7 @@ pub fn renameatW(
16641664
16651665 rename_info.* = .{
16661666 .ReplaceIfExists = ReplaceIfExists,
1667 .RootDirectory = if (std.fs.path.isAbsoluteWindowsW(new_path_w)) null else new_dir_fd,
1667 .RootDirectory = if (old_dir_fd == new_dir_fd or std.fs.path.isAbsoluteWindowsW(new_path_w)) null else new_dir_fd,
16681668 .FileNameLength = @intCast(u32, new_path.len * 2), // already checked error.NameTooLong
16691669 .FileName = undefined,
16701670 };