| ... | @@ -254,17 +254,8 @@ pub const File = struct { | ... | @@ -254,17 +254,8 @@ pub const File = struct { |
| 254 | // into a new inode, remove the original file, and rename the copy to match | 254 | // into a new inode, remove the original file, and rename the copy to match |
| 255 | // the original file. This is super messy, but there doesn't seem any other | 255 | // the original file. This is super messy, but there doesn't seem any other |
| 256 | // way to please the XNU. | 256 | // way to please the XNU. |
| 257 | const random_bytes_len = 12; | | |
| 258 | comptime const random_sub_path_len = std.base64.Base64Encoder.calcSize(random_bytes_len); | | |
| 259 | const emit = base.options.emit orelse return; | 257 | const emit = base.options.emit orelse return; |
| 260 | var random_bytes: [random_bytes_len]u8 = undefined; | 258 | try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{}); |
| 261 | try std.crypto.randomBytes(&random_bytes); | | |
| 262 | var random_sub_path: [random_sub_path_len]u8 = undefined; | | |
| 263 | fs.base64_encoder.encode(&random_sub_path, &random_bytes); | | |
| 264 | const tmp_file_name = try mem.join(base.allocator, "_", &[_][]const u8{ emit.sub_path, random_sub_path[0..] }); | | |
| 265 | defer base.allocator.free(tmp_file_name); | | |
| 266 | try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, tmp_file_name, .{}); | | |
| 267 | try emit.directory.handle.rename(tmp_file_name, emit.sub_path); | | |
| 268 | } | 259 | } |
| 269 | f.close(); | 260 | f.close(); |
| 270 | base.file = null; | 261 | base.file = null; |