Skip to content

Commit 89334fa

Browse files
committed
windows: better error handling for DeleteFile.
1 parent 73c04d4 commit 89334fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/std/os/windows.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil
933933
.FILE_IS_A_DIRECTORY => return error.IsDir,
934934
.NOT_A_DIRECTORY => return error.NotDir,
935935
.SHARING_VIOLATION => return error.FileBusy,
936-
.CANNOT_DELETE => return error.AccessDenied,
936+
.ACCESS_DENIED => return error.AccessDenied,
937937
else => return unexpectedStatus(rc),
938938
}
939939
var file_dispo = FILE_DISPOSITION_INFORMATION{
@@ -950,6 +950,10 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil
950950
switch (rc) {
951951
.SUCCESS => return,
952952
.DIRECTORY_NOT_EMPTY => return error.DirNotEmpty,
953+
.INVALID_PARAMETER => unreachable,
954+
.CANNOT_DELETE => return error.AccessDenied,
955+
.MEDIA_WRITE_PROTECTED => return error.AccessDenied,
956+
.ACCESS_DENIED => return error.AccessDenied,
953957
else => return unexpectedStatus(rc),
954958
}
955959
}

0 commit comments

Comments
 (0)