| ... | ... | @@ -280,24 +280,19 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void { |
| 280 | 280 | |
| 281 | 281 | fn writeFile(file: *File, mod: *Module) !void { |
| 282 | 282 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; |
| 283 | | var af = mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf) catch |err| { |
| 284 | | std.log.warn("unable to create builtin atomic file '{}{s}'", .{ |
| 285 | | mod.root, mod.root_src_path, |
| 286 | | }); |
| 287 | | return err; |
| 288 | | }; |
| 283 | var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf); |
| 289 | 284 | defer af.deinit(); |
| 290 | | af.file.writeAll(file.source) catch |err| { |
| 291 | | std.log.warn("unable to write builtin file data to '{}{s}'", .{ |
| 292 | | mod.root, mod.root_src_path, |
| 293 | | }); |
| 294 | | return err; |
| 295 | | }; |
| 296 | | af.finish() catch |err| { |
| 297 | | std.log.warn("unable to rename atomic builtin file into '{}{s}'", .{ |
| 298 | | mod.root, mod.root_src_path, |
| 299 | | }); |
| 300 | | return err; |
| 285 | try af.file.writeAll(file.source); |
| 286 | af.finish() catch |err| switch (err) { |
| 287 | error.AccessDenied => switch (builtin.os.tag) { |
| 288 | .windows => { |
| 289 | // Very likely happened due to another process or thread |
| 290 | // simultaneously creating the same, correct builtin.zig file. |
| 291 | // This is not a problem; ignore it. |
| 292 | }, |
| 293 | else => return err, |
| 294 | }, |
| 295 | else => return err, |
| 301 | 296 | }; |
| 302 | 297 | |
| 303 | 298 | file.stat = .{ |
| ... | ... | @@ -307,6 +302,7 @@ fn writeFile(file: *File, mod: *Module) !void { |
| 307 | 302 | }; |
| 308 | 303 | } |
| 309 | 304 | |
| 305 | const builtin = @import("builtin"); |
| 310 | 306 | const std = @import("std"); |
| 311 | 307 | const Allocator = std.mem.Allocator; |
| 312 | 308 | const build_options = @import("build_options"); |