From 49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 09:15:41 -0300 Subject: A Save into a directory that is not there says no such directory, ENOENT It failed EIO with `file not found`, which named no file that was missing. It says `Save : no such directory`, and a late failure saying `no such` answers ENOENT, as a builtin's does. Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 1afb1e24..27cbf383 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5271,8 +5271,16 @@ pub const Pardes = struct { // The `-%` spelling fs.zig already uses for "make this dirty". f.saved_revision = f.revision -% 1; }; - var what: [limits.host_path_cap + 8]u8 = undefined; - p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path}) catch "Save", err); + var what: [limits.host_path_cap + 32]u8 = undefined; + // A write into a directory that is not there: said so, in the words + // a mount reads as ENOENT. + const parent = std.fs.path.dirname(path) orelse "/"; + const no_dir = err == error.FileNotFound or err == error.NotDir or + (if (comptime hosted) (if (filesystem.localPath(parent)) |local| !exec.isDirectory(local) else false) else false); + if (no_dir) + p.reportFailure(id, std.fmt.bufPrint(&what, "Save {s}: no such directory", .{path}) catch "Save: no such directory") + else + p.reportError(id, std.fmt.bufPrint(&what, "Save {s}", .{path}) catch "Save", err); const said = if (p.panes[id]) |pane| pane.msg[0..pane.msg_len] else "Save failed"; const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len); @memcpy(p.fs.late_failure[0..kept.len], kept); -- cgit v1.3