Exclusive file creation
This commit is contained in:
+2
-3
@@ -61,9 +61,8 @@ pub fn init(alloc: std.mem.Allocator, fil: File) !Archive {
|
|||||||
try std.Thread.getCpuCount(),
|
try std.Thread.getCpuCount(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/// Create the Archive dictating the amount of threads & memory used.
|
/// Create the Archive dictating the amount of threads used for extraction.
|
||||||
/// If trying to extract a full archive, a large memory size & thread count could help.
|
/// If you're planning on only interacting with a small number of files, it should be fine to use few (or one) threads.
|
||||||
/// If you're planning on only interacting with a small number of files, it should be fine to use few threads and a small memory size.
|
|
||||||
pub fn initAdvanced(alloc: std.mem.Allocator, fil: File, offset: u64, threads: usize) !Archive {
|
pub fn initAdvanced(alloc: std.mem.Allocator, fil: File, offset: u64, threads: usize) !Archive {
|
||||||
var super: Superblock = undefined;
|
var super: Superblock = undefined;
|
||||||
const red = try fil.pread(@ptrCast(&super), offset);
|
const red = try fil.pread(@ptrCast(&super), offset);
|
||||||
|
|||||||
+1
-1
@@ -378,7 +378,7 @@ fn extractThread(
|
|||||||
///
|
///
|
||||||
/// Assumes the inode is a file or ext_file type.
|
/// Assumes the inode is a file or ext_file type.
|
||||||
fn extractRegFile(self: Inode, alloc: std.mem.Allocator, archive: *Archive, path: []const u8, options: ExtractionOptions) !void {
|
fn extractRegFile(self: Inode, alloc: std.mem.Allocator, archive: *Archive, path: []const u8, options: ExtractionOptions) !void {
|
||||||
var fil = try std.fs.cwd().createFile(path, .{});
|
var fil = try std.fs.cwd().createFile(path, .{ .exclusive = true });
|
||||||
defer fil.close();
|
defer fil.close();
|
||||||
var wrt = fil.writer(&[0]u8{});
|
var wrt = fil.writer(&[0]u8{});
|
||||||
var dat_rdr = try self.dataReader(alloc, archive);
|
var dat_rdr = try self.dataReader(alloc, archive);
|
||||||
|
|||||||
Reference in New Issue
Block a user