From 7e6fc8c9f62bc3dc08e24856cc647fa0adefb32c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 9 Nov 2026 03:31:45 -0300 Subject: idioms: std.Io's names for the std.fs aliases left in Addon, Kind, rollback and replica (std.Io.Dir.path, std.Io.Dir.max_path_bytes), and the window's handover dump written and removed through the shell's io (Io.Dir.writeFile at 0600, deleteFile) instead of libc open, write and unlink Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/gui.zig | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gui') 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) } }); -- cgit v1.3