summaryrefslogtreecommitdiff
path: root/src/Installation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Installation.zig')
-rw-r--r--src/Installation.zig9
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
132pub fn getAvailableList(config: Config) !Installations { 135pub 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
166fn parseInstallation(config: Config, name: []const u8, value: JsonValue) !?Installation { 169fn 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 }