I can't tell whats wrong with this code. Its hanging at the second line from bottom. I would expect it to read the entire file into the array list.
const std = @import("std");
test {
var dir = std.testing.tmpDir(.{});
defer dir.cleanup();
var f = try dir.dir.createFile("foo", .{ .read = true }); // create file for writing and reading
defer f.close();
try f.writeAll("foobar" ** 10);
try f.seekTo(0);
var buf: [std.heap.pageSize()]u8 = undefined;
var freader = f.reader(&buf);
var al = std.ArrayListUnmanaged(u8){};
var w = std.io.Writer.Allocating.fromArrayList(std.testing.allocator, &al);
_ = try freader.interface.streamRemaining(&w.writer); // hangs here
std.debug.print("{s}\n", .{al.items});
}
I'm using this zig version which i think is the most recent tarball available.
$ zig version
0.15.0-dev.1034+bd97b6618
Also, is this the correct way to init a File.Reader? I assume you can provide any sized buffer you wish but thats just a guess.