summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Addon.zig8
-rw-r--r--src/Kind.zig4
-rw-r--r--src/gui/gui.zig15
-rw-r--r--src/replica.zig10
-rw-r--r--src/rollback.zig4
5 files changed, 20 insertions, 21 deletions
diff --git a/src/Addon.zig b/src/Addon.zig
index fa41f774..cadf28d7 100644
--- a/src/Addon.zig
+++ b/src/Addon.zig
@@ -206,7 +206,7 @@ pub fn scan() []const Loaded {
if (data.len > 0) scanDir(data, std.fmt.bufPrint(&dir_buf, "{s}/addons", .{data}) catch "", crashed.slice());
var exe: [4096]u8 = undefined;
const n = std.c.readlink("/proc/self/exe", &exe, exe.len);
- if (n > 0) if (std.fs.path.dirname(exe[0..@intCast(n)])) |bin| if (std.fs.path.dirname(bin)) |prefix|
+ if (n > 0) if (std.Io.Dir.path.dirname(exe[0..@intCast(n)])) |bin| if (std.Io.Dir.path.dirname(bin)) |prefix|
scanDir(data, std.fmt.bufPrint(&dir_buf, "{s}/lib/pardes/addons", .{prefix}) catch "", crashed.slice());
return found[0..nfound];
}
@@ -506,7 +506,7 @@ pub fn run(p: *Pardes, id: usize, arg: ?[]const u8) void {
var target: [pardes.effect_path_cap]u8 = undefined;
if (op == .load) {
const dir = std.mem.trimEnd(u8, if (p.panes[id]) |pane| Pardes.paneDir(pane) else p.sessionDir(), "/");
- const path = if (std.fs.path.isAbsolute(rest)) rest else std.fmt.bufPrint(&target, "{s}/{s}", .{ dir, rest }) catch return p.reportFailure(id, "Addon: that path is too long");
+ const path = if (std.Io.Dir.path.isAbsolute(rest)) rest else std.fmt.bufPrint(&target, "{s}/{s}", .{ dir, rest }) catch return p.reportFailure(id, "Addon: that path is too long");
if (path.len > pardes.effect_path_cap) return p.reportFailure(id, "Addon: that path is too long");
return p.emit(.{ .addon = .{ .op = .load, .pane = @intCast(id), .arg = .from(path) } });
}
@@ -540,7 +540,7 @@ pub fn openPanes(p: *const Pardes, name: []const u8) usize {
pub fn landed(p: *Pardes, op: Op, pane: u8, l: Loaded) void {
const id = if (pane < p.panes.len and p.panes[pane] != null) pane else p.view().active;
var said: [320]u8 = undefined;
- const base = std.fs.path.basename(l.path);
+ const base = std.Io.Dir.path.basename(l.path);
if (op == .reload) {
var why: Why = .{};
if (!swap(p, l, &why)) {
@@ -651,7 +651,7 @@ fn fail(why: *Why, comptime fmt: []const u8, args: anytype) bool {
/// loaded|refused: why` a line (`-` for no path, no hash).
pub fn list(p: *const Pardes, out: *std.ArrayList(u8), gpa: std.mem.Allocator) !void {
for (p.kinds.kinds[0..p.kinds.n]) |*e| {
- const name = if (e.nameOf().len > 0) e.nameOf() else std.fs.path.basename(e.path.slice());
+ const name = if (e.nameOf().len > 0) e.nameOf() else std.Io.Dir.path.basename(e.path.slice());
try out.print(gpa, "{s} {d} {d}.{d} {d} {s} ", .{ name, e.version, e.abi >> 16, e.abi & 0xffff, if (e.refused) 0 else openPanes(p, name), if (e.path.len > 0) e.path.slice() else "-" });
if (std.mem.allEqual(u8, &e.hash, 0)) try out.append(gpa, '-') else try out.print(gpa, "{x}", .{e.hash});
try out.print(gpa, " {s}\n", .{e.why.slice()});
diff --git a/src/Kind.zig b/src/Kind.zig
index 0a8fc7ae..2f40c8ea 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -972,7 +972,7 @@ fn moreFound(p: *Pardes, id: usize, rows: []const u8) void {
const rf = if (rp.file) |*f| f else return;
const o = if (rf.output) |*x| x else return;
const content = std.mem.concat(p.gpa, u8, &.{ rf.content, rows }) catch |err| return p.reportError(id, "found", err);
- pardes.panes.Output.fillResults(p, id, std.fs.path.dirname(rf.path) orelse p.sessionDir(), .search, o.arg(), content, null) catch |err| p.reportError(id, "found", err);
+ pardes.panes.Output.fillResults(p, id, std.Io.Dir.path.dirname(rf.path) orelse p.sessionDir(), .search, o.arg(), content, null) catch |err| p.reportError(id, "found", err);
}
fn same(o: Outcome) Outcome {
@@ -1136,7 +1136,7 @@ pub var seed_base: u64 = 0;
/// directory, refilled when one is there, whose rows n and N walk from the
/// kind's pane, a Look of one going to its kind (look.zig lookKind).
fn textPane(p: *Pardes, id: usize, slot: *const Slot, name: []const u8, text: []const u8) void {
- const dir = std.fs.path.dirname(slot.path) orelse p.sessionDir();
+ const dir = std.Io.Dir.path.dirname(slot.path) orelse p.sessionDir();
const content = p.gpa.dupe(u8, text) catch |err| return p.reportError(id, name, err);
pardes.panes.Output.fillResults(p, id, dir, .kind, name, content, null) catch |err| p.reportError(id, name, err);
}
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 212fe5ad..4e1f76dc 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3570,16 +3570,15 @@ fn handOver(ctx: ?*anyopaque, seq: u32, bytes: []const u8) void {
const s = shellOf(ctx);
const Handover = pardes.Handover;
const path = Handover.dumpPath(s.gpa, seq) catch |err| return s.core.update(.{ .handed = .{ .seq = seq, .failure = @errorName(err) } });
- const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true, .CLOEXEC = true }, @as(libc.mode_t, 0o600));
- const written = fd >= 0 and host_io.writeFd(fd, bytes);
- if (fd >= 0) _ = libc.close(fd);
- if (!written) {
- _ = libc.unlink(path);
+ // A dump not written, or not carried, goes: what failed is said.
+ const cwd = std.Io.Dir.cwd();
+ cwd.writeFile(s.io, .{ .sub_path = path, .data = bytes, .flags = .{ .permissions = .fromMode(0o600) } }) catch {
+ cwd.deleteFile(s.io, path) catch {};
s.gpa.free(path);
return s.core.update(.{ .handed = .{ .seq = seq, .failure = "cannot write its dump" } });
- }
+ };
const job = s.gpa.create(Handover.Job) catch {
- _ = libc.unlink(path);
+ cwd.deleteFile(s.io, path) catch {};
s.gpa.free(path);
return s.core.update(.{ .handed = .{ .seq = seq, .failure = "out of memory" } });
};
@@ -3603,7 +3602,7 @@ fn handOver(ctx: ?*anyopaque, seq: u32, bytes: []const u8) void {
job.geometry_len = geometry.len;
}
s.core.handover.start(s.io, job) catch |err| {
- _ = libc.unlink(path);
+ cwd.deleteFile(s.io, path) catch {};
s.gpa.free(path);
s.gpa.destroy(job);
return s.core.update(.{ .handed = .{ .seq = seq, .failure = @errorName(err) } });
diff --git a/src/replica.zig b/src/replica.zig
index b88b1328..8b0f8c8e 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -3113,7 +3113,7 @@ fn deliver(a: *Authority, screens: *Screens, peer: u16, r: *Replica, comptime wh
/// The blob cache of a test, in its own directory (never the user's).
fn testCache(tmp: *std.testing.TmpDir, buf: *[4200]u8, cap: u64) !Cache {
- var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ var dir_buf: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)];
return Cache.of(try std.fmt.bufPrint(buf, "{s}/" ++ Cache.name, .{dir}), cap);
}
@@ -3994,8 +3994,8 @@ test "a replica joined after a pane closed: the session's jump to it, its Panes
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);
defer a.deinit();
// A file looked at and closed: a jump to it, Recent's, a closed pane.
- var cwd: [std.fs.max_path_bytes]u8 = undefined;
- var line: [std.fs.max_path_bytes + 32]u8 = undefined;
+ var cwd: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var line: [std.Io.Dir.max_path_bytes + 32]u8 = undefined;
const dir = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd)));
_ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/build.zig.zon", .{dir}) });
_ = try a.local(.{ .command = "Del" });
@@ -4045,8 +4045,8 @@ test "a replica's Del of a file its session's Recent knows asks the host what th
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);
defer a.deinit();
- var cwd: [std.fs.max_path_bytes]u8 = undefined;
- var line: [std.fs.max_path_bytes + 32]u8 = undefined;
+ var cwd: [std.Io.Dir.max_path_bytes]u8 = undefined;
+ var line: [std.Io.Dir.max_path_bytes + 32]u8 = undefined;
const dir = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd)));
_ = try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/build.zig.zon", .{dir}) });
// Joined while it is open: in the session's Recent, in no replica's.
diff --git a/src/rollback.zig b/src/rollback.zig
index ccd056fd..461ba45b 100644
--- a/src/rollback.zig
+++ b/src/rollback.zig
@@ -765,7 +765,7 @@ test "a file's location rows are pinned whole, with what they own, and come back
/// `Look <name>`, the name a file of the repository's, absolute.
fn lookAt(buf: []u8, name: []const u8) ![]const u8 {
- var cwd: [std.fs.max_path_bytes]u8 = undefined;
+ var cwd: [std.Io.Dir.max_path_bytes]u8 = undefined;
const dir = std.c.getcwd(&cwd, cwd.len) orelse return error.NoCwd;
return std.fmt.bufPrint(buf, "Look {s}/{s}", .{ std.mem.span(@as([*:0]u8, @ptrCast(dir))), name });
}
@@ -776,7 +776,7 @@ test "a rollback leaves the store and Recent as a speculation left them: they li
const gpa = e.allocator();
const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml", .image_allocator = gpa, .tree_sitter_allocator = gpa, .frame_allocator = gpa });
p.pump(.{}) catch {};
- var line: [std.fs.max_path_bytes + 16]u8 = undefined;
+ var line: [std.Io.Dir.max_path_bytes + 16]u8 = undefined;
p.update(.{ .command = try lookAt(&line, "build.zig.zon") });
p.update(.{ .command = "Del" });
p.pump(.{}) catch {};