Returns the number of bytes read. If the number read is smaller than the total bytes from all the buffers, it means the file reached the end. Reaching the end of a file is not an error condition.
The iovecs
parameter is mutable because:
- This function needs to mutate the fields in order to handle partial reads from the underlying OS layer.
- The OS layer expects pointer addresses to be inside the application’s address space even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer addresses when the length is zero. So this function modifies the iov_base fields when the length is zero.
Related open issue: https://github.com/ziglang/zig/issues/7699