Skip to content

Commit

Permalink
add zip cmdline tool
Browse files Browse the repository at this point in the history
  • Loading branch information
marler8997 committed May 5, 2024
1 parent 8068ac0 commit 09c47a2
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 2 deletions.
10 changes: 10 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ pub fn build(b: *std.Build) !void {
const install = b.addInstallArtifact(unzip, .{});
b.step("unzip", "Build/install the unzip cmdline tool").dependOn(&install.step);
}
{
const zip = b.addExecutable(.{
.name = "zip",
.root_source_file = b.path("zip.zig"),
.target = target,
.optimize = optimize,
});
const install = b.addInstallArtifact(zip, .{});
b.step("zip", "Build/install the zip cmdline tool").dependOn(&install.step);
}
}

fn addTest(
Expand Down
4 changes: 2 additions & 2 deletions unzip.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn fatal(comptime fmt: []const u8, args: anytype) noreturn {
}

fn usage() noreturn {
std.log.err("Usage: unzip [-d DIR] ZIP_FILE", .{});
std.io.getStdErr().writer().print("Usage: unzip [-d DIR] ZIP_FILE\n", .{}) catch |e| @panic(@errorName(e));
std.process.exit(1);
}

Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn main() !void {
const zip_file = std.fs.cwd().openFile(zip_file_arg, .{}) catch |err|
fatal("open '{s}' failed: {s}", .{zip_file_arg, @errorName(err)});
defer zip_file.close();
try @import("zip.zig").extract(out_dir, zip_file.seekableStream(), .{
try @import("lib/zip.zig").extract(out_dir, zip_file.seekableStream(), .{
.allow_backslashes = true,
});
}
Loading

0 comments on commit 09c47a2

Please sign in to comment.