-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix carridge return * Remove debug logging * Remove more debug logging * the launcher launches now :D * Add zig-cache to gitignore * Add .cubyz * Delete zig-cache directory * Made main not return !void * Replace four spaces with tabs * Made it work on platforms other than windows (hopefully) * Fix * Changes * Remove .gitignore * Replace proc.cwd with proc.cwd_dir on non-windows systems * Fixed proc.cwd_dir * Replace osArchName with @TagName * Added executable bit * Removed useless lines
- Loading branch information
1 parent
5cac5b3
commit baf8481
Showing
5 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.zig-cache/ | ||
zig-cache/ | ||
zig-out/ | ||
logs/ | ||
settings.json | ||
gui_layout.json | ||
|
||
.cubyz/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const std = @import("std"); | ||
const fs = std.fs; | ||
const zip = std.zip; | ||
const tar = std.tar; | ||
const compress = std.compress; | ||
|
||
pub fn decompress_zip(zip_path: []const u8, output_dir: []const u8) !void { | ||
const zip_file = try fs.cwd().openFile(zip_path, .{}); | ||
defer zip_file.close(); | ||
|
||
fs.cwd().makeDir(output_dir) catch {}; | ||
|
||
var output_dir_handle = try fs.cwd().openDir(output_dir, .{}); | ||
defer output_dir_handle.close(); | ||
|
||
try zip.extract(output_dir_handle, zip_file.seekableStream(), .{}); | ||
} | ||
|
||
pub fn decompress_tar_xz(zip_path: []const u8, output_dir: []const u8) !void { | ||
const tar_file = try fs.cwd().openFile(zip_path, .{}); | ||
defer tar_file.close(); | ||
|
||
fs.cwd().makeDir(output_dir) catch {}; | ||
|
||
var output_dir_handle = try fs.cwd().openDir(output_dir, .{}); | ||
defer output_dir_handle.close(); | ||
|
||
var xz_decompress = try compress.xz.decompress(std.heap.page_allocator, tar_file.reader()); | ||
defer xz_decompress.deinit(); | ||
|
||
try std.tar.pipeToFileSystem(output_dir_handle, xz_decompress.reader(), .{}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const std = @import("std"); | ||
const utils = @import("utils.zig"); | ||
const http = std.http; | ||
const fs = std.fs; | ||
|
||
pub fn fetchAndSave(allocator: utils.NeverFailingAllocator, url: []const u8, out: []const u8) !void { | ||
var stream = fs.cwd().createFile(out, .{}) catch try fs.cwd().openFile(out, .{}); | ||
defer stream.close(); | ||
|
||
var client = http.Client{.allocator = allocator.allocator}; | ||
defer client.deinit(); | ||
|
||
var response: std.ArrayList(u8) = std.ArrayList(u8).init(allocator.allocator); | ||
defer response.deinit(); | ||
|
||
const result = try client.fetch(.{ | ||
.method = .GET, | ||
.response_storage = .{ .dynamic = &response }, | ||
.max_append_size = std.math.maxInt(usize), | ||
.location = .{ | ||
.url = url | ||
} | ||
}); | ||
|
||
_ = result; | ||
|
||
try stream.writeAll(response.items); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters