Function seekTo [src]
Prototype
pub fn seekTo(r: *Reader, offset: u64) Reader.SeekError!void Parameters
r: *Readeroffset: u64 Possible Errors
In WASI, this error may occur when the file descriptor does not hold the required rights to seek on it.
Seeking fell back to reading, and reached the end before the requested seek position.
pos remains at the end of the file.
Seeking fell back to reading, which failed.
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 seekTo(r: *Reader, offset: u64) Reader.SeekError!void {
switch (r.mode) {
.positional, .positional_reading => {
setPosAdjustingBuffer(r, offset);
},
.streaming, .streaming_reading => {
if (offset >= r.pos) return Reader.seekBy(r, @intCast(offset - r.pos));
if (r.seek_err) |err| return err;
posix.lseek_SET(r.file.handle, offset) catch |err| {
r.seek_err = err;
return err;
};
setPosAdjustingBuffer(r, offset);
},
.failure => return r.seek_err.?,
}
}