summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 1a2f132f..1172fa78 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1125,6 +1125,12 @@ pub const Save = struct {
// silent success.
if (c.pane.file == null and !c.pane.isTerminal())
return c.p.reportFailure(c.id, if (c.pane.hasPdf()) "Save: a PDF pane has no text to save" else "Save: an image pane has no text to save");
+ // A directory's listing is no file to write, bare or to a path, as
+ // acme's Put does nothing in a directory window.
+ if (c.pane.file) |file| if (file.listing != null) {
+ var said: [limits.host_path_cap + 48]u8 = undefined;
+ return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Save: {s} is a directory", .{file.path[0..@min(file.path.len, limits.host_path_cap)]}) catch "Save: a directory pane has no file to save");
+ };
const path = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (path.len > 0) return exec.saveTo(c.p, c.id, path);
// A `+` name is a generated pane's (+Tutor), no file of its own:
@@ -1505,7 +1511,7 @@ pub const LocationsConfig = struct {
try c.p.locations_config.write(&out.writer);
try out.writer.writeByte('\n');
const content = try out.toOwnedSlice();
- const dir = if (c.pane.file) |file| std.fs.path.dirname(file.path) orelse "/" else c.pane.cwdSlice();
+ const dir = if (c.pane.file) |file| panes.Dir.ofName(file.path) else c.pane.cwdSlice();
try panes.Output.fillResults(c.p, c.id, dir, .{ .cmd = .LocationsConfig }, "", content, null);
}
};
@@ -2085,7 +2091,7 @@ const Board = struct {
p.gpa.free(content);
return error.MissingPane;
};
- const dir = if (pane.file) |f| (std.fs.path.dirname(f.path) orelse "/") else pane.cwdSlice();
+ const dir = if (pane.file) |f| panes.Dir.ofName(f.path) else pane.cwdSlice();
try panes.Output.fillResults(p, id, dir, from, "", content, null);
}