Skip to content

Commit c8da03a

Browse files
squeek502andrewrk
authored andcommitted
Fix compile error in Dir.deleteTreeMinStackSize and add test
Follow up to #13073
1 parent 9b45dc1 commit c8da03a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/std/fs.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ pub const Dir = struct {
22612261
/// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size.
22622262
/// This is slower than `deleteTree` but uses less stack space.
22632263
pub fn deleteTreeMinStackSize(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2264-
return self.deleteTreeMinStackWithKindHint(sub_path, .File);
2264+
return self.deleteTreeMinStackSizeWithKindHint(sub_path, .File);
22652265
}
22662266

22672267
fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void {

lib/std/fs/test.zig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,22 @@ test "makePath, put some files in it, deleteTree" {
677677
}
678678
}
679679

680+
test "makePath, put some files in it, deleteTreeMinStackSize" {
681+
var tmp = tmpDir(.{});
682+
defer tmp.cleanup();
683+
684+
try tmp.dir.makePath("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");
685+
try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
686+
try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
687+
try tmp.dir.deleteTreeMinStackSize("os_test_tmp");
688+
if (tmp.dir.openDir("os_test_tmp", .{})) |dir| {
689+
_ = dir;
690+
@panic("expected error");
691+
} else |err| {
692+
try testing.expect(err == error.FileNotFound);
693+
}
694+
}
695+
680696
test "makePath in a directory that no longer exists" {
681697
if (builtin.os.tag == .windows) return error.SkipZigTest; // Windows returns FileBusy if attempting to remove an open dir
682698

0 commit comments

Comments
 (0)