commit 89334fae205d02874fec1571e0637cfa1894ff1e (tree)
parent 73c04d4b2891b8e1c32261b59c0d17f4447f9658
Author: xEgoist <egoist@egoistic.dev>
Date: Mon, 17 Apr 2023 22:35:04 -0500
windows: better error handling for DeleteFile.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git 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),
}
}