mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 17:15:37 +00:00
Windows: Handle ERROR_DIRECTORY in std.fs.deleteDirAbsolute when called on a file path
ERROR_DIRECTORY (267) is returned from kernel32.RemoveDirectoryW if the path is not a directory. Note also that os.DirectDirError already includes NotDir Before: error.Unexpected: GetLastError(267): The directory name is invalid. After: error: NotDir
This commit is contained in:
parent
f7b6957fb4
commit
95a5f6bf2d
@ -745,6 +745,7 @@ pub const RemoveDirectoryError = error{
|
||||
FileNotFound,
|
||||
DirNotEmpty,
|
||||
Unexpected,
|
||||
NotDir,
|
||||
};
|
||||
|
||||
pub fn RemoveDirectory(dir_path: []const u8) RemoveDirectoryError!void {
|
||||
@ -757,6 +758,7 @@ pub fn RemoveDirectoryW(dir_path_w: [*:0]const u16) RemoveDirectoryError!void {
|
||||
switch (kernel32.GetLastError()) {
|
||||
.PATH_NOT_FOUND => return error.FileNotFound,
|
||||
.DIR_NOT_EMPTY => return error.DirNotEmpty,
|
||||
.DIRECTORY => return error.NotDir,
|
||||
else => |err| return unexpectedError(err),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user