diff --git a/lib/std/os.zig b/lib/std/os.zig index 90e738d775..93e4b42667 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -2355,7 +2355,10 @@ pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void { /// Windows-only. Same as `unlink` except the parameter is null-terminated, WTF16 encoded. pub fn unlinkW(file_path_w: []const u16) UnlinkError!void { - return windows.DeleteFile(file_path_w, .{ .dir = std.fs.cwd().fd }); + windows.DeleteFile(file_path_w, .{ .dir = std.fs.cwd().fd }) catch |err| switch (err) { + error.DirNotEmpty => unreachable, // we're not passing .remove_dir = true + else => |e| return e, + }; } pub const UnlinkatError = UnlinkError || error{