Commit c8da03a0e1
lib/std/fs/test.zig
@@ -677,6 +677,22 @@ test "makePath, put some files in it, deleteTree" {
}
}
+test "makePath, put some files in it, deleteTreeMinStackSize" {
+ var tmp = tmpDir(.{});
+ defer tmp.cleanup();
+
+ try tmp.dir.makePath("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");
+ try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
+ try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
+ try tmp.dir.deleteTreeMinStackSize("os_test_tmp");
+ if (tmp.dir.openDir("os_test_tmp", .{})) |dir| {
+ _ = dir;
+ @panic("expected error");
+ } else |err| {
+ try testing.expect(err == error.FileNotFound);
+ }
+}
+
test "makePath in a directory that no longer exists" {
if (builtin.os.tag == .windows) return error.SkipZigTest; // Windows returns FileBusy if attempting to remove an open dir
lib/std/fs.zig
@@ -2261,7 +2261,7 @@ pub const Dir = struct {
/// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size.
/// This is slower than `deleteTree` but uses less stack space.
pub fn deleteTreeMinStackSize(self: Dir, sub_path: []const u8) DeleteTreeError!void {
- return self.deleteTreeMinStackWithKindHint(sub_path, .File);
+ return self.deleteTreeMinStackSizeWithKindHint(sub_path, .File);
}
fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void {