Fixed threads == 0 causing single threaded extraction.

Set exclusive file creation
This commit is contained in:
Caleb J. Gardner
2026-02-12 05:08:16 -06:00
parent 567dea8a0b
commit 48f4235875
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -74,7 +74,7 @@ pub fn initAdvanced(alloc: std.mem.Allocator, fil: File, offset: u64, threads: u
.parent_alloc = alloc, .parent_alloc = alloc,
.alloc = .{ .child_allocator = alloc }, .alloc = .{ .child_allocator = alloc },
// .fixed_buf = fixed_buf, // .fixed_buf = fixed_buf,
.thread_count = threads, .thread_count = if (threads > 0) threads else try std.Thread.getCpuCount(),
.fil = .init(fil, offset), .fil = .init(fil, offset),
.decomp = switch (super.compression) { .decomp = switch (super.compression) {
.gzip => Decomp.gzipDecompress, .gzip => Decomp.gzipDecompress,
+3 -3
View File
@@ -15,7 +15,7 @@ const help_mgs =
\\ \\
\\ -o <offset> Start reading the archive at the given offset. \\ -o <offset> Start reading the archive at the given offset.
\\ \\
\\ -p <threads> Specify how many threads to use. If no present, the system's logical cores count is used. \\ -p <threads> Specify how many threads to use. If no present or zero, the system's logical cores count is used.
\\ \\
\\ --help Display this messages \\ --help Display this messages
\\ --version Display the version \\ --version Display the version
@@ -83,9 +83,9 @@ fn handleArgs(alloc: std.mem.Allocator, out: *Writer) !void {
}; };
continue; continue;
} else if (std.mem.eql(u8, arg, "--version")) { } else if (std.mem.eql(u8, arg, "--version")) {
try out.print("zig-unsquashfs version ", .{}); try out.print("zig-unsquashfs v", .{});
try config.version.format(out); try config.version.format(out);
try out.print("\nBuilt using Zig {s} with {} backend in {} mode.\n", .{ builtin.zig_version_string, builtin.zig_backend, builtin.mode }); try out.print("\nBuilt using Zig {s}\n", .{ builtin.zig_version_string, builtin.zig_backend, builtin.mode });
std.process.exit(0); std.process.exit(0);
return; return;
} else if (std.mem.eql(u8, arg, "--help")) { } else if (std.mem.eql(u8, arg, "--help")) {