std.Io.File: add readStreaming

I resisted adding this because it's generally better to create a
File.Reader instead, but we do need a simple wrapper around the vtable
function, and there are use cases for it such as std.Progress.
This commit is contained in:
Andrew Kelley 2025-12-26 16:40:41 -08:00
parent f160d5f979
commit 28810f5e3d

View file

@ -499,6 +499,14 @@ pub fn setTimestampsNow(file: File, io: Io) SetTimestampsError!void {
return io.vtable.fileSetTimestampsNow(io.userdata, file);
}
/// Returns 0 on stream end or if `buffer` has no space available for data.
///
/// See also:
/// * `reader`
pub fn readStreaming(file: File, io: Io, buffer: []const []u8) Reader.Error!usize {
return io.vtable.fileReadStreaming(io.userdata, file, buffer);
}
pub const ReadPositionalError = Reader.Error || error{Unseekable};
/// Returns 0 on stream end or if `buffer` has no space available for data.