Function copyRangeAll [src]
Prototype
pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64
Parameters
in: File
in_offset: u64
out: File
out_offset: u64
len: u64
Possible Errors
In WASI, this error occurs when the file descriptor does not hold the required rights to read from it.
reading a timerfd with CANCEL_ON_SET will lead to this error when the clock goes through a discontinuous change
Connection reset by peer.
fd_in
is not open for reading; or fd_out
is not open for writing;
or the APPEND
flag is set for fd_out
.
Unable to read file due to lock.
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.
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.
This error occurs in Linux if the process to be read from no longer exists.
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.
This error occurs when no global event loop is configured, and reading from the file descriptor would block.
Source
pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: u64) CopyRangeError!u64 {
var total_bytes_copied: u64 = 0;
var in_off = in_offset;
var out_off = out_offset;
while (total_bytes_copied < len) {
const amt_copied = try copyRange(in, in_off, out, out_off, len - total_bytes_copied);
if (amt_copied == 0) return total_bytes_copied;
total_bytes_copied += amt_copied;
in_off += amt_copied;
out_off += amt_copied;
}
return total_bytes_copied;
}