diff options
| author | 2022-07-19 22:56:37 +0300 | |
|---|---|---|
| committer | 2022-07-19 22:56:37 +0300 | |
| commit | 8cc1a3808b91e81d5904f727058413e082eed91f (patch) | |
| tree | 8b92b4d718f44b47ff6d7858746b4bb52aa3be1d /src | |
| parent | Added support for config files (diff) | |
| download | zup-8cc1a3808b91e81d5904f727058413e082eed91f.tar.gz zup-8cc1a3808b91e81d5904f727058413e082eed91f.tar.xz zup-8cc1a3808b91e81d5904f727058413e082eed91f.zip | |
Maintenance commit
Diffstat (limited to 'src')
| -rw-r--r-- | src/Installation.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Installation.zig b/src/Installation.zig index 031b59a..5efe128 100644 --- a/src/Installation.zig +++ b/src/Installation.zig | |||
| @@ -76,10 +76,13 @@ pub fn getInstalledList(allocator: Allocator) !Installations { | |||
| 76 | var zup_data = try xdg.openDataHome(allocator, "zup"); | 76 | var zup_data = try xdg.openDataHome(allocator, "zup"); |
| 77 | defer zup_data.close(); | 77 | defer zup_data.close(); |
| 78 | 78 | ||
| 79 | var zup_data_iterable = try zup_data.openIterableDir(".", .{}); | ||
| 80 | defer zup_data_iterable.close(); | ||
| 81 | |||
| 79 | var installations = Installations.init(allocator); | 82 | var installations = Installations.init(allocator); |
| 80 | errdefer Installation.deinitMap(allocator, &installations); | 83 | errdefer Installation.deinitMap(allocator, &installations); |
| 81 | 84 | ||
| 82 | var it = zup_data.iterate(); | 85 | var it = zup_data_iterable.iterate(); |
| 83 | while (try it.next()) |item| { | 86 | while (try it.next()) |item| { |
| 84 | if (item.kind != .Directory) { | 87 | if (item.kind != .Directory) { |
| 85 | continue; | 88 | continue; |
| @@ -131,7 +134,7 @@ pub fn isInstalled(allocator: Allocator, name: []const u8) !bool { | |||
| 131 | 134 | ||
| 132 | pub fn getAvailableList(config: Config) !Installations { | 135 | pub fn getAvailableList(config: Config) !Installations { |
| 133 | const allocator = config.allocator; | 136 | const allocator = config.allocator; |
| 134 | 137 | ||
| 135 | var json_str = try curl.easyDownload(allocator, "https://ziglang.org/download/index.json"); | 138 | var json_str = try curl.easyDownload(allocator, "https://ziglang.org/download/index.json"); |
| 136 | defer allocator.free(json_str); | 139 | defer allocator.free(json_str); |
| 137 | 140 | ||
| @@ -165,7 +168,7 @@ pub fn getAvailableList(config: Config) !Installations { | |||
| 165 | 168 | ||
| 166 | fn parseInstallation(config: Config, name: []const u8, value: JsonValue) !?Installation { | 169 | fn parseInstallation(config: Config, name: []const u8, value: JsonValue) !?Installation { |
| 167 | const allocator = config.allocator; | 170 | const allocator = config.allocator; |
| 168 | 171 | ||
| 169 | if (value != .Object) { | 172 | if (value != .Object) { |
| 170 | return error.JsonSchema; | 173 | return error.JsonSchema; |
| 171 | } | 174 | } |