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, 9 insertions, 1 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index c42d4978..77e1169d 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1150,10 +1150,18 @@ pub const Get = struct {
return panes.Dir.show(c.p, c.id, c.id);
}
if (!panes.Output.fileTraits(f.output).saves) return c.p.reportFailure(c.id, "Get: only a file pane takes it");
- if (ctl.getRefused(c.p, c.pane, "Get")) |said| return c.p.reportFailure(c.id, said);
var failed: anyerror = error.Unexpected;
var home_buf: [4096]u8 = undefined;
const path = if (typed.len == 0) c.pane.file.?.path else std.fs.path.resolvePosix(c.p.scratch.allocator(), &.{ Pardes.paneDir(c.pane), @import("fs.zig").expandHome(typed, &home_buf) }) catch return;
+ // A file that is not there, or a directory, is said before unsaved
+ // edits are asked about: there would be nothing to load over them.
+ if (comptime pardes.hosted) if (typed.len > 0) if (@import("fs.zig").localPath(path)) |local| {
+ var said: [320]u8 = undefined;
+ const kind = exec.kindOf(local);
+ if (kind == null or kind.? == .directory)
+ return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Get: {s}: {s}", .{ path[0..@min(path.len, 256)], if (kind == null) "no such file" else "is a directory" }) catch "Get: no such file");
+ };
+ if (ctl.getRefused(c.p, c.pane, "Get")) |said| return c.p.reportFailure(c.id, said);
const errno = if (typed.len == 0) ctl.get(c.p, c.pane, &failed) else ctl.getFile(c.p, c.pane, path, &failed);
if (errno != 0) {
var said: [320]u8 = undefined;