mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 00:57:04 +00:00
std: use fifo.pump in writeFileAllUnseekable
This commit is contained in:
parent
e873668d38
commit
01d1a8a783
@ -724,14 +724,12 @@ pub const File = struct {
|
||||
|
||||
try in_file.reader().skipBytes(args.in_offset, .{ .buf_size = 4096 });
|
||||
|
||||
var buffer: [4096]u8 = undefined;
|
||||
const in_len = args.in_len orelse math.maxInt(u64);
|
||||
var index: usize = 0;
|
||||
while (index < in_len) {
|
||||
const ask = math.min(buffer.len, in_len - index);
|
||||
const amt = try in_file.read(buffer[0..ask]);
|
||||
if (amt == 0) break;
|
||||
index += try self.write(buffer[0..amt]);
|
||||
var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init();
|
||||
if (args.in_len) |len| {
|
||||
var stream = std.io.earlyEOFReader(in_file.reader(), len);
|
||||
try fifo.pump(stream.reader(), self.writer());
|
||||
} else {
|
||||
try fifo.pump(in_file.reader(), self.writer());
|
||||
}
|
||||
|
||||
try self.writevAll(trailers);
|
||||
|
Loading…
Reference in New Issue
Block a user