summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 09:15:41 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd (patch)
treea1303e7c3eb8a6a2687a90cb973e16412f45471d /src/pardes.zig
parent36241daca2aaf90cc8933dffd95fc3cd6216e2b7 (diff)
downloadpardes-49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd.tar.gz
pardes-49d5bf5ebfe4a84070b7eac1e9d8ac52e1cc45fd.zip
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 <path>: no such directory`, and a late failure saying `no such` answers ENOENT, as a builtin's does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig12
1 files changed, 10 insertions, 2 deletions
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);