diff --git a/src/download.zig b/src/download.zig index 9001de9..0e106ab 100644 --- a/src/download.zig +++ b/src/download.zig @@ -148,7 +148,6 @@ fn downloadAndExtract( download_node.end(); var extract_node = root_node.start("Extracting", 1); - const c_allocator = std.heap.c_allocator; // ~/.zm/versions/zig-macos-x86_64-0.10.0.tar.xz const data_allocator = tools.getAllocator(); @@ -175,12 +174,16 @@ fn downloadAndExtract( const downloaded_file = try zvm_dir.openFile(downloaded_file_path, .{}); defer downloaded_file.close(); - _ = try lib.extract_tarxz_to_dir(c_allocator, zvm_dir_version, downloaded_file); + if (builtin.os.tag == .windows) { + try lib.extract_zip_dir(zvm_dir_version, downloaded_file); + } else { + try lib.extract_tarxz_to_dir(allocator, zvm_dir_version, downloaded_file); + } + extract_node.end(); var result: [32]u8 = undefined; sha256.final(&result); - //std.debug.print("Hash computation complete. Hash: {s}\n", .{std.fmt.fmtSliceHexLower(&result)}); return result; } diff --git a/src/extract.zig b/src/extract.zig index 6175342..ae55c1c 100644 --- a/src/extract.zig +++ b/src/extract.zig @@ -3,14 +3,10 @@ const builtin = @import("builtin"); const tools = @import("tools.zig"); pub fn extract_tarxz_to_dir(allocator: std.mem.Allocator, outDir: std.fs.Dir, file: std.fs.File) !void { - if (builtin.os.tag == .windows) { - try extract_zip_dir(outDir, file); - } else { - var buffered_reader = std.io.bufferedReader(file.reader()); - var decompressed = try std.compress.xz.decompress(allocator, buffered_reader.reader()); - defer decompressed.deinit(); - try std.tar.pipeToFileSystem(outDir, decompressed.reader(), .{ .mode_mode = .executable_bit_only, .strip_components = 1 }); - } + var buffered_reader = std.io.bufferedReader(file.reader()); + var decompressed = try std.compress.xz.decompress(allocator, buffered_reader.reader()); + defer decompressed.deinit(); + try std.tar.pipeToFileSystem(outDir, decompressed.reader(), .{ .mode_mode = .executable_bit_only, .strip_components = 1 }); } pub fn extract_zip_dir(outDir: std.fs.Dir, file: std.fs.File) !void {