summaryrefslogtreecommitdiff
path: root/src/ninep/pane.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/pane.zig')
-rw-r--r--src/ninep/pane.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 704f1ac8..52ae9494 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -399,8 +399,8 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply
return switch (file) {
.name => name: {
const out = p.fs.stage(p.gpa);
- out.appendSlice(p.gpa, nameOf(p, pane)) catch {};
- out.append(p.gpa, '\n') catch {};
+ out.appendSlice(p.gpa, nameOf(p, pane)) catch break :name Reply.fail(req.tag, E.NOMEM);
+ out.append(p.gpa, '\n') catch break :name Reply.fail(req.tag, E.NOMEM);
break :name tree.stagedReply(p, req);
},
.body => readBody(p, req, id, pane),
@@ -440,13 +440,13 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply
/// happens to bound nothing.
fn readRange(p: *Pardes, req: Req, r: ?State.Range) Reply {
const out = p.fs.stage(p.gpa);
- if (r) |range| out.print(p.gpa, "{d:>11} {d:>11} ", .{ range.q0, range.q1 }) catch {};
+ if (r) |range| out.print(p.gpa, "{d:>11} {d:>11} ", .{ range.q0, range.q1 }) catch return Reply.fail(req.tag, E.NOMEM);
return tree.stagedReply(p, req);
}
fn readFlag(p: *Pardes, req: Req, on: bool) Reply {
const out = p.fs.stage(p.gpa);
- out.appendSlice(p.gpa, if (on) "1\n" else "0\n") catch {};
+ out.appendSlice(p.gpa, if (on) "1\n" else "0\n") catch return Reply.fail(req.tag, E.NOMEM);
return tree.stagedReply(p, req);
}
@@ -886,14 +886,14 @@ fn writeName(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply {
// Words 9ns maps to EINVAL, as every refusal of a name here.
if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, unnamed(pane));
var home_buf: [4096]u8 = undefined;
- const full = std.fs.path.resolvePosix(p.scratch.allocator(), &.{ pardes.Pardes.paneDir(pane), fs.expandHome(name, &home_buf) }) catch
+ const full = std.Io.Dir.path.resolvePosix(p.scratch.allocator(), &.{ pardes.Pardes.paneDir(pane), fs.expandHome(name, &home_buf) }) catch
return Reply.fail(req.tag, E.NOMEM);
- if (!std.fs.path.isAbsolute(full) or full.len >= 4096) return tree.failText(req.tag, E.INVAL, "invalid file name: longer than a path may be");
+ if (!std.Io.Dir.path.isAbsolute(full) or full.len >= 4096) return tree.failText(req.tag, E.INVAL, "invalid file name: longer than a path may be");
// A directory (`~`, `/`, `foo/`) is no file to name a pane after: a
// Save could only fail. Said now, EISDIR.
const is_dir = name[name.len - 1] == '/' or std.mem.eql(u8, full, "/") or
(if (fs.localPath(full)) |local| exec.kindOf(local) == .directory else false);
- if (is_dir) return tree.failText(req.tag, E.ISDIR, std.fmt.bufPrint(&p.fs.ename, "name: {s} is a directory, not a file", .{full[0..@min(full.len, 256)]}) catch "name: is a directory, not a file");
+ if (is_dir) return tree.failText(req.tag, E.ISDIR, std.fmt.bufPrint(&p.fs.ename, "name: {s} is a directory, not a file", .{full[0..@min(full.len, 256)]}) catch unreachable); // 256 fit 320
nameBuffer(p, id, full, false) catch |err| return Reply.fail(req.tag, switch (err) {
error.OutOfMemory => E.NOMEM,
else => E.INVAL,
@@ -906,7 +906,7 @@ fn writeName(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply {
pub fn nameBuffer(p: *Pardes, id: usize, full: []const u8, preserve_tag: bool) !void {
const pane = p.panes[id] orelse return error.NoPane;
const f = fileOf(pane) orelse return error.NotFile;
- if (!std.fs.path.isAbsolute(full) or full.len == 0 or full.len >= 4096)
+ if (!std.Io.Dir.path.isAbsolute(full) or full.len == 0 or full.len >= 4096)
return error.InvalidName;
if (std.mem.indexOfAny(u8, full, "\x00\n") != null) return error.InvalidName;
if (std.mem.eql(u8, f.path, full)) return;
@@ -949,7 +949,7 @@ pub fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize {
const qf = fileOf(q) orelse continue;
const o = qf.output orelse continue;
if (std.meta.activeTag(o.from) != .errors) continue;
- if (!std.mem.eql(u8, std.fs.path.dirname(qf.path) orelse "", dir)) continue;
+ if (!std.mem.eql(u8, std.Io.Dir.path.dirname(qf.path) orelse "", dir)) continue;
return spliceBody(p, q, qf.content.len, qf.content.len, text);
}
const free = p.freeSlot() orelse return null;