commit 28810f5e3d41597116773b2eb6686f3d8e272b36 (tree)
parent f160d5f979c9f2bcc98ef0169a879a76d0234ed2
Author: Andrew Kelley <andrew@ziglang.org>
Date: Fri, 26 Dec 2025 16:40:41 -0800
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.
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/std/Io/File.zig b/lib/std/Io/File.zig
@@ -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.