From 9dd7b684d504c2275c3ee999f661f4f40a2bb323 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Thu, 29 Jan 2026 20:43:56 +0100 Subject: FileSwapper: track swapped state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/fs.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fs.zig b/src/fs.zig index 4a3b049..08ad7ee 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -13,6 +13,7 @@ pub const FileSwapper = struct { target_path: []const u8, tmp_path: []const u8, tmp: std.fs.File, + swapped: *bool, pub fn createAt(alloc: std.mem.Allocator, path: []const u8) !FileSwapper { const target_dir = std.fs.path.dirname(path) orelse "."; @@ -32,11 +33,15 @@ pub const FileSwapper = struct { const f = try std.fs.cwd().createFile(tmp_path, .{}); + const swapped = try alloc.create(bool); + swapped.* = false; + return .{ .allocator = alloc, .target_path = path, .tmp_path = tmp_path, .tmp = f, + .swapped = swapped, }; } @@ -63,6 +68,8 @@ pub const FileSwapper = struct { std.fs.cwd(), self.target_path, ); + + self.swapped.* = true; } pub fn close(self: FileSwapper) void { -- cgit 1.4.1