Function copy_file_range [src]

Prototype

pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) CopyFileRangeError!usize

Parameters

fd_in: fd_toff_in: ?*i64fd_out: fd_toff_out: ?*i64len: usizeflags: u32

Possible Errors

BadFileFlags

If infd is not open for reading or outfd is not open for writing, or opened for writing with O_APPEND, or if infd and outfd refer to the same file.

CorruptedData

Corrupted data was detected while reading from a file system.

FileTooBig

If the copy exceeds the process's file size limit or the maximum file size for the file system outfd re- sides on.

InputOutput

An I/O error occurred while reading/writing the files.

Interrupted

A signal interrupted the system call before it could be completed. This may happen for files on some NFS mounts. When this happens, the values pointed to by inoffp and outoffp are reset to the initial values for the system call.

InvalidArguments

One of:

  • infd and outfd refer to the same file and the byte ranges overlap.
  • The flags argument is not zero.
  • Either infd or outfd refers to a file object that is not a regular file.
IsDir

Either infd or outfd refers to a directory.

NoSpaceLeft

File system that stores outfd is full.

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.

Source

pub fn copy_file_range(fd_in: fd_t, off_in: ?*i64, fd_out: fd_t, off_out: ?*i64, len: usize, flags: u32) CopyFileRangeError!usize { const rc = std.c.copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); switch (errno(rc)) { .SUCCESS => return @intCast(rc), .BADF => return error.BadFileFlags, .FBIG => return error.FileTooBig, .INTR => return error.Interrupted, .INVAL => return error.InvalidArguments, .IO => return error.InputOutput, .INTEGRITY => return error.CorruptedData, .ISDIR => return error.IsDir, .NOSPC => return error.NoSpaceLeft, else => |err| return unexpectedErrno(err), } }