commit a301dbf29ca4d7d68253ea25cfffdc0d0207ae0b
parent 650599dad0118f667a0f3e26ee9350f18cce0cc8
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 7 Sep 2024 16:29:11 -0400
fs: handle path::too_long in rmdirall
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/util.ha b/fs/util.ha
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
// (c) Hare authors <https://harelang.org>
+use errors;
use path;
use strings;
@@ -103,8 +104,13 @@ export fn dirents_free(dirents: []dirent) void = {
// Removes a directory, and anything in it.
export fn rmdirall(fs: *fs, path: str) (void | error) = {
- let buf = path::init(path)!;
- return rmdirall_path(fs, &buf);
+ match (path::init(path)) {
+ case let buf: path::buffer =>
+ return rmdirall_path(fs, &buf);
+ case let err: path::error =>
+ assert(err is path::too_long);
+ return errors::noentry;
+ };
};
fn rmdirall_path(fs: *fs, buf: *path::buffer) (void | error) = {