Function seekToUnbuffered [src]
Asserts that no data is currently buffered.
Prototype
pub fn seekToUnbuffered(w: *Writer, offset: u64) Writer.SeekError!void Parameters
w: *Writeroffset: u64 Possible Errors
In WASI, this error may occur when the file descriptor does not hold the required rights to seek on it.
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 seekToUnbuffered(w: *Writer, offset: u64) Writer.SeekError!void {
assert(w.interface.buffered().len == 0);
switch (w.mode) {
.positional, .positional_reading => {
w.pos = offset;
},
.streaming, .streaming_reading => {
if (w.seek_err) |err| return err;
posix.lseek_SET(w.file.handle, offset) catch |err| {
w.seek_err = err;
return err;
};
w.pos = offset;
},
.failure => return w.seek_err.?,
}
}