diff options
| author | 2022-09-12 03:59:42 +0300 | |
|---|---|---|
| committer | 2022-09-12 03:59:42 +0300 | |
| commit | 9d3d2747b393843266053c7fa52e846ffd482cc4 (patch) | |
| tree | 3bd0e20ea1e152e62ed664ae3f763d5354debea1 /src | |
| parent | Update clap (diff) | |
| download | zup-9d3d2747b393843266053c7fa52e846ffd482cc4.tar.gz zup-9d3d2747b393843266053c7fa52e846ffd482cc4.tar.xz zup-9d3d2747b393843266053c7fa52e846ffd482cc4.zip | |
Zig update
Diffstat (limited to 'src')
| -rw-r--r-- | src/Config.zig | 6 | ||||
| -rw-r--r-- | src/Installation.zig | 3 | ||||
| -rw-r--r-- | src/install.zig | 8 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/Config.zig b/src/Config.zig index a7affa0..4eb58cc 100644 --- a/src/Config.zig +++ b/src/Config.zig | |||
| @@ -44,13 +44,13 @@ pub fn init(allocator: Allocator) !Config { | |||
| 44 | 44 | ||
| 45 | try self.readConfig(file); | 45 | try self.readConfig(file); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | return self; | 48 | return self; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | pub fn deinit(self: *Config) void { | 51 | pub fn deinit(self: *Config) void { |
| 52 | self.supported_targets.deinit(); | 52 | self.supported_targets.deinit(); |
| 53 | 53 | ||
| 54 | self.* = undefined; | 54 | self.* = undefined; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| @@ -85,7 +85,7 @@ fn readConfig(self: *Config, file: File) !void { | |||
| 85 | const cross_target = try CrossTarget.parse(.{ | 85 | const cross_target = try CrossTarget.parse(.{ |
| 86 | .arch_os_abi = supported_target.String, | 86 | .arch_os_abi = supported_target.String, |
| 87 | }); | 87 | }); |
| 88 | const native_target_info = try NativeTargetInfo.detect(allocator, cross_target); | 88 | const native_target_info = try NativeTargetInfo.detect(cross_target); |
| 89 | try self.supported_targets.append(native_target_info.target); | 89 | try self.supported_targets.append(native_target_info.target); |
| 90 | } | 90 | } |
| 91 | } | 91 | } |
diff --git a/src/Installation.zig b/src/Installation.zig index 5efe128..4f7a48d 100644 --- a/src/Installation.zig +++ b/src/Installation.zig | |||
| @@ -153,7 +153,8 @@ pub fn getAvailableList(config: Config) !Installations { | |||
| 153 | 153 | ||
| 154 | var it = vt.root.Object.iterator(); | 154 | var it = vt.root.Object.iterator(); |
| 155 | while (it.next()) |kv| { | 155 | while (it.next()) |kv| { |
| 156 | if (try parseInstallation(config, kv.key_ptr.*, kv.value_ptr.*)) |*installation| { | 156 | var installation_opt = try parseInstallation(config, kv.key_ptr.*, kv.value_ptr.*); |
| 157 | if (installation_opt) |*installation| { | ||
| 157 | errdefer installation.deinit(); | 158 | errdefer installation.deinit(); |
| 158 | 159 | ||
| 159 | var name = try allocator.dupe(u8, kv.key_ptr.*); | 160 | var name = try allocator.dupe(u8, kv.key_ptr.*); |
diff --git a/src/install.zig b/src/install.zig index f9c7309..27db4bb 100644 --- a/src/install.zig +++ b/src/install.zig | |||
| @@ -20,7 +20,7 @@ pub const max_args = 1; | |||
| 20 | 20 | ||
| 21 | pub fn main(comptime Result: type, config: Config, res: Result) !void { | 21 | pub fn main(comptime Result: type, config: Config, res: Result) !void { |
| 22 | const allocator = config.allocator; | 22 | const allocator = config.allocator; |
| 23 | 23 | ||
| 24 | var available = try Installation.getAvailableList(config); | 24 | var available = try Installation.getAvailableList(config); |
| 25 | defer Installation.deinitMap(allocator, &available); | 25 | defer Installation.deinitMap(allocator, &available); |
| 26 | 26 | ||
| @@ -80,13 +80,15 @@ pub fn perform(allocator: Allocator, name: []const u8, force: bool, available: I | |||
| 80 | try archive.supportFormat(.all); | 80 | try archive.supportFormat(.all); |
| 81 | try archive.openFilename(tmpname, 10240); | 81 | try archive.openFilename(tmpname, 10240); |
| 82 | 82 | ||
| 83 | while (try archive.nextHeader()) |*entry| { | 83 | while (try archive.nextHeader()) |entry_c| { |
| 84 | var entry = entry_c; | ||
| 85 | |||
| 84 | const source = entry.pathname(); | 86 | const source = entry.pathname(); |
| 85 | const dest = try preparePathname(allocator, installation_dir, source); | 87 | const dest = try preparePathname(allocator, installation_dir, source); |
| 86 | defer allocator.free(dest); | 88 | defer allocator.free(dest); |
| 87 | 89 | ||
| 88 | entry.setPathname(dest); | 90 | entry.setPathname(dest); |
| 89 | try archive.extract(entry.*, 0); | 91 | try archive.extract(entry, 0); |
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | std.log.info("Installed to {s}", .{installation_dir}); | 94 | std.log.info("Installed to {s}", .{installation_dir}); |