Function writeFileAllUnseekable [src]

Does not try seeking in either of the File parameters. See writeFileAll as an alternative to calling this.

Prototype

pub fn writeFileAllUnseekable(self: File, in_file: File, args: WriteFileOptions) WriteFileError!void

Parameters

self: Filein_file: Fileargs: WriteFileOptions

Possible Errors

AccessDenied ReadError

In WASI, this error occurs when the file descriptor does not hold the required rights to read from it.

BrokenPipe ReadError
Canceled ReadError

reading a timerfd with CANCEL_ON_SET will lead to this error when the clock goes through a discontinuous change

ConnectionResetByPeer WriteError

Connection reset by peer.

ConnectionTimedOut ReadError
DeviceBusy WriteError
DiskQuota WriteError
EndOfStream
FileTooBig WriteError
InputOutput ReadError
InvalidArgument WriteError
IsDir ReadError
LockViolation ReadError

Unable to read file due to lock.

MessageTooBig WriteError

The socket type requires that message be sent atomically, and the size of the message to be sent made this impossible. The message is not transmitted.

NoDevice WriteError

This error occurs when a device gets disconnected before or mid-flush while it's being written to - errno(6): No such device or address.

NoSpaceLeft WriteError
NotOpenForReading ReadError
NotOpenForWriting WriteError
OperationAborted ReadError
PermissionDenied WriteError
ProcessNotFound ReadError

This error occurs in Linux if the process to be read from no longer exists.

SocketNotConnected ReadError
SystemResources ReadError
Unexpected UnexpectedError

The Operating System returned an undocumented error code.

This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.

When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.

WouldBlock ReadError

This error occurs when no global event loop is configured, and reading from the file descriptor would block.

Source

pub fn writeFileAllUnseekable(self: File, in_file: File, args: WriteFileOptions) WriteFileError!void { const headers = args.headers_and_trailers[0..args.header_count]; const trailers = args.headers_and_trailers[args.header_count..]; try self.writevAll(headers); try in_file.reader().skipBytes(args.in_offset, .{ .buf_size = 4096 }); var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init(); if (args.in_len) |len| { var stream = std.io.limitedReader(in_file.reader(), len); try fifo.pump(stream.reader(), self.writer()); } else { try fifo.pump(in_file.reader(), self.writer()); } try self.writevAll(trailers); }