diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-26 21:12:20 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-26 21:12:20 +0100 |
| commit | ebb2f208159c46fed3aadfcefd2a5524bc46011b (patch) | |
| tree | 1ab51cc0e8819b43c867247d8b26ddb63ae8da8d /src/link.zig | |
| parent | a8f8d8221595a422b61ceca8835c677f6830799d (diff) | |
| download | zig-ebb2f208159c46fed3aadfcefd2a5524bc46011b.tar.gz zig-ebb2f208159c46fed3aadfcefd2a5524bc46011b.zip | |
stage2 macho: Dir.copyFile does the rename for us!
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/link.zig b/src/link.zig index 98082570b7..e8a9f3d730 100644 --- a/src/link.zig +++ b/src/link.zig @@ -254,17 +254,8 @@ pub const File = struct { // into a new inode, remove the original file, and rename the copy to match // the original file. This is super messy, but there doesn't seem any other // way to please the XNU. - const random_bytes_len = 12; - comptime const random_sub_path_len = std.base64.Base64Encoder.calcSize(random_bytes_len); const emit = base.options.emit orelse return; - var random_bytes: [random_bytes_len]u8 = undefined; - try std.crypto.randomBytes(&random_bytes); - var random_sub_path: [random_sub_path_len]u8 = undefined; - fs.base64_encoder.encode(&random_sub_path, &random_bytes); - const tmp_file_name = try mem.join(base.allocator, "_", &[_][]const u8{ emit.sub_path, random_sub_path[0..] }); - defer base.allocator.free(tmp_file_name); - try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, tmp_file_name, .{}); - try emit.directory.handle.rename(tmp_file_name, emit.sub_path); + try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{}); } f.close(); base.file = null; |
