const std = @import("std"); const zelda = @import("zelda"); const Allocator = std.mem.Allocator; const File = std.fs.File; // TODO: zelda should be able to do this internally so I wouldn't have to allocate memory for the // file pub fn downloadToFile(allocator: Allocator, file: *File, url: []const u8) !void { var response = try zelda.get(allocator, url); defer response.deinit(); if (response.status_code.group() != .success) { std.log.err("HTTP Error: {}", .{response.status_code}); return error.HttpError; } if (response.body) |body| { try file.writer().writeAll(body); } else { std.log.warn("Downloaded nothing from {s}...", .{url}); } }