authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2020-06-04 15:59:48-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-06-04 22:52:53-04:00
log95a5f6bf2dd822d4a67bef0fda3074dabea2d8c2
treeba36dd6774dfa6194626b8204e7d76f845dffabb
parentf7b6957fb4e6c70e6917abf519943f3f5d3e5660

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

1 files changed, 2 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+2
......@@ -745,6 +745,7 @@ pub const RemoveDirectoryError = error{
745745 FileNotFound,
746746 DirNotEmpty,
747747 Unexpected,
748 NotDir,
748749};
749750
750751pub fn RemoveDirectory(dir_path: []const u8) RemoveDirectoryError!void {
......@@ -757,6 +758,7 @@ pub fn RemoveDirectoryW(dir_path_w: [*:0]const u16) RemoveDirectoryError!void {
757758 switch (kernel32.GetLastError()) {
758759 .PATH_NOT_FOUND => return error.FileNotFound,
759760 .DIR_NOT_EMPTY => return error.DirNotEmpty,
761 .DIRECTORY => return error.NotDir,
760762 else => |err| return unexpectedError(err),
761763 }
762764 }