| ... | @@ -11,7 +11,6 @@ const common = @import("./../common.zig"); | ... | @@ -11,7 +11,6 @@ const common = @import("./../common.zig"); |
| 11 | // | 11 | // |
| 12 | | 12 | |
| 13 | pub const Module = struct { | 13 | pub const Module = struct { |
| 14 | alloc: std.mem.Allocator, | | |
| 15 | is_sys_lib: bool, | 14 | is_sys_lib: bool, |
| 16 | is_framework: bool, | 15 | is_framework: bool, |
| 17 | id: string, | 16 | id: string, |
| ... | @@ -40,7 +39,6 @@ pub const Module = struct { | ... | @@ -40,7 +39,6 @@ pub const Module = struct { |
| 40 | } | 39 | } |
| 41 | } | 40 | } |
| 42 | return Module{ | 41 | return Module{ |
| 43 | .alloc = alloc, | | |
| 44 | .is_sys_lib = false, | 42 | .is_sys_lib = false, |
| 45 | .is_framework = false, | 43 | .is_framework = false, |
| 46 | .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), | 44 | .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), |
| ... | @@ -65,10 +63,10 @@ pub const Module = struct { | ... | @@ -65,10 +63,10 @@ pub const Module = struct { |
| 65 | return std.mem.eql(u8, self.id, another.id); | 63 | return std.mem.eql(u8, self.id, another.id); |
| 66 | } | 64 | } |
| 67 | | 65 | |
| 68 | pub fn get_hash(self: Module, cdpath: string) !string { | 66 | pub fn get_hash(self: Module, alloc: std.mem.Allocator, cdpath: string) !string { |
| 69 | const file_list_1 = try u.file_list(self.alloc, try std.mem.concat(self.alloc, u8, &.{ cdpath, "/", self.clean_path })); | 67 | const file_list_1 = try u.file_list(alloc, try std.mem.concat(alloc, u8, &.{ cdpath, "/", self.clean_path })); |
| 70 | | 68 | |
| 71 | var file_list_2 = std.ArrayList(string).init(self.alloc); | 69 | var file_list_2 = std.ArrayList(string).init(alloc); |
| 72 | defer file_list_2.deinit(); | 70 | defer file_list_2.deinit(); |
| 73 | for (file_list_1) |item| { | 71 | for (file_list_1) |item| { |
| 74 | const _a = u.trim_prefix(item, cdpath); | 72 | const _a = u.trim_prefix(item, cdpath); |
| ... | @@ -86,15 +84,15 @@ pub const Module = struct { | ... | @@ -86,15 +84,15 @@ pub const Module = struct { |
| 86 | | 84 | |
| 87 | const h = &std.crypto.hash.Blake3.init(.{}); | 85 | const h = &std.crypto.hash.Blake3.init(.{}); |
| 88 | for (file_list_2.items) |item| { | 86 | for (file_list_2.items) |item| { |
| 89 | const abs_path = try std.fs.path.join(self.alloc, &.{ cdpath, self.clean_path, item }); | 87 | const abs_path = try std.fs.path.join(alloc, &.{ cdpath, self.clean_path, item }); |
| 90 | const file = try std.fs.cwd().openFile(abs_path, .{}); | 88 | const file = try std.fs.cwd().openFile(abs_path, .{}); |
| 91 | defer file.close(); | 89 | defer file.close(); |
| 92 | const input = try file.reader().readAllAlloc(self.alloc, u.mb * 100); | 90 | const input = try file.reader().readAllAlloc(alloc, u.mb * 100); |
| 93 | h.update(input); | 91 | h.update(input); |
| 94 | } | 92 | } |
| 95 | var out: [32]u8 = undefined; | 93 | var out: [32]u8 = undefined; |
| 96 | h.final(&out); | 94 | h.final(&out); |
| 97 | const hex = try std.fmt.allocPrint(self.alloc, "blake3-{x}", .{std.fmt.fmtSliceHexLower(out[0..])}); | 95 | const hex = try std.fmt.allocPrint(alloc, "blake3-{x}", .{std.fmt.fmtSliceHexLower(out[0..])}); |
| 98 | return hex; | 96 | return hex; |
| 99 | } | 97 | } |
| 100 | | 98 | |