From 89334fae205d02874fec1571e0637cfa1894ff1e Mon Sep 17 00:00:00 2001 From: xEgoist Date: Mon, 17 Apr 2023 22:35:04 -0500 Subject: [PATCH] windows: better error handling for DeleteFile. --- lib/std/os/windows.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index e195989e7e..8d2df4c7ef 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -933,7 +933,7 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil .FILE_IS_A_DIRECTORY => return error.IsDir, .NOT_A_DIRECTORY => return error.NotDir, .SHARING_VIOLATION => return error.FileBusy, - .CANNOT_DELETE => return error.AccessDenied, + .ACCESS_DENIED => return error.AccessDenied, else => return unexpectedStatus(rc), } var file_dispo = FILE_DISPOSITION_INFORMATION{ @@ -950,6 +950,10 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil switch (rc) { .SUCCESS => return, .DIRECTORY_NOT_EMPTY => return error.DirNotEmpty, + .INVALID_PARAMETER => unreachable, + .CANNOT_DELETE => return error.AccessDenied, + .MEDIA_WRITE_PROTECTED => return error.AccessDenied, + .ACCESS_DENIED => return error.AccessDenied, else => return unexpectedStatus(rc), } }