summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig15
1 files changed, 7 insertions, 8 deletions
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) } });