authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-10-05 19:51:43-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-10-05 19:51:43-07:00
logdb0829c15ab883b9efe704414fcf8149a3d83026
tree0933f12d006d7f7cd5f7e36e52347d783d21fa6f
parent34f180901eaa0fcd5e3bddc6f353604da8bd7e1f

fs.Dir.deleteTree: Fix some handling of NotDir error in deleteFile calls

We don't control sub_path so it may contain directory components; therefore, NotDir is a potential error when acting on sub_path.

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

lib/std/fs.zig+2-2
...@@ -2187,6 +2187,7 @@ pub const Dir = struct {...@@ -2187,6 +2187,7 @@ pub const Dir = struct {
2187 } else |err| switch (err) {2187 } else |err| switch (err) {
2188 error.FileNotFound => break :handle_entry,2188 error.FileNotFound => break :handle_entry,
21892189
2190 // Impossible because we do not pass any path separators.
2190 error.NotDir => unreachable,2191 error.NotDir => unreachable,
21912192
2192 error.IsDir => {2193 error.IsDir => {
...@@ -2268,8 +2269,6 @@ pub const Dir = struct {...@@ -2268,8 +2269,6 @@ pub const Dir = struct {
2268 } else |err| switch (err) {2269 } else |err| switch (err) {
2269 error.FileNotFound => return,2270 error.FileNotFound => return,
22702271
2271 error.NotDir => unreachable,
2272
2273 error.IsDir => {2272 error.IsDir => {
2274 treat_as_dir = true;2273 treat_as_dir = true;
2275 continue :handle_entry;2274 continue :handle_entry;
...@@ -2281,6 +2280,7 @@ pub const Dir = struct {...@@ -2281,6 +2280,7 @@ pub const Dir = struct {
2281 error.NameTooLong,2280 error.NameTooLong,
2282 error.SystemResources,2281 error.SystemResources,
2283 error.ReadOnlyFileSystem,2282 error.ReadOnlyFileSystem,
2283 error.NotDir,
2284 error.FileSystem,2284 error.FileSystem,
2285 error.FileBusy,2285 error.FileBusy,
2286 error.BadPathName,2286 error.BadPathName,