diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-12-09 15:03:17 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-12-09 15:03:17 -0700 |
| commit | 6e636064e6d993ebb0eb6ef386f5f19cb8727fe3 (patch) | |
| tree | 7ed7dafe4b2755cc43f18a6669d42bfded1c6c38 | |
| parent | ae3fd86dcc6f39601aa26ce1a6dc51a0db5cbf30 (diff) | |
| download | zig-6e636064e6d993ebb0eb6ef386f5f19cb8727fe3.tar.gz zig-6e636064e6d993ebb0eb6ef386f5f19cb8727fe3.zip | |
MoveFileEx can return ACCESS_DENIED
I observed this on Windows 10, trying to use MoveFileEx with
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH
to overwrite a running executable.
| -rw-r--r-- | lib/std/os/windows.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index e976bb7e82..b994720ce9 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -865,7 +865,7 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil } } -pub const MoveFileError = error{ FileNotFound, Unexpected }; +pub const MoveFileError = error{ FileNotFound, AccessDenied, Unexpected }; pub fn MoveFileEx(old_path: []const u8, new_path: []const u8, flags: DWORD) MoveFileError!void { const old_path_w = try sliceToPrefixedFileW(old_path); @@ -877,6 +877,7 @@ pub fn MoveFileExW(old_path: [*:0]const u16, new_path: [*:0]const u16, flags: DW if (kernel32.MoveFileExW(old_path, new_path, flags) == 0) { switch (kernel32.GetLastError()) { .FILE_NOT_FOUND => return error.FileNotFound, + .ACCESS_DENIED => return error.AccessDenied, else => |err| return unexpectedError(err), } } |
