diff --git a/lib/std/io/buffered_atomic_file.zig b/lib/std/io/buffered_atomic_file.zig index b450a578c..81c040da2 100644 --- a/lib/std/io/buffered_atomic_file.zig +++ b/lib/std/io/buffered_atomic_file.zig @@ -15,8 +15,12 @@ pub const BufferedAtomicFile = struct { /// TODO when https://github.com/ziglang/zig/issues/2761 is solved /// this API will not need an allocator - /// TODO integrate this with Dir API - pub fn create(allocator: *mem.Allocator, dest_path: []const u8) !*BufferedAtomicFile { + pub fn create( + allocator: *mem.Allocator, + dir: fs.Dir, + dest_path: []const u8, + atomic_file_options: fs.Dir.AtomicFileOptions, + ) !*BufferedAtomicFile { var self = try allocator.create(BufferedAtomicFile); self.* = BufferedAtomicFile{ .atomic_file = undefined, @@ -26,7 +30,7 @@ pub const BufferedAtomicFile = struct { }; errdefer allocator.destroy(self); - self.atomic_file = try fs.cwd().atomicFile(dest_path, .{}); + self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options); errdefer self.atomic_file.deinit(); self.file_stream = self.atomic_file.file.outStream(); diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index 5c469e4c8..38ab49ccc 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -339,7 +339,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void { while (try dir_it.next()) |entry| { if (entry.kind == .Directory or mem.endsWith(u8, entry.name, ".zig")) { - const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ real_path, entry.name }); + const full_path = try fs.path.join(fmt.allocator, &[_][]const u8{ file_path, entry.name }); try fmtPath(fmt, full_path, check_mode); } } @@ -377,7 +377,7 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void { fmt.any_error = true; } } else { - const baf = try io.BufferedAtomicFile.create(fmt.allocator, real_path); + const baf = try io.BufferedAtomicFile.create(fmt.allocator, fs.cwd(), real_path, .{}); defer baf.destroy(); const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree);