There isno readUnti* now?

var buffer: [1024]u8 = undefined; 
var reader = file.reader(&buffer);
while (try 
reader.readUntilDelimiterOrEof(&buffer, '\n')) |line| {
...
}

The above code works before. However it reports error: no field or member function named ‘readUntilDelimiterOrEof’ in ‘fs.File.Reader’ !

$zig version

0.15.1

Regards !

This stuff changed, and i wouldn’t be surprised if it changes again.
You can track changes if you’re on bleeding edge, or stick to tagged releases and read the release notes for migration.

1 Like

https://ziglang.org/documentation/0.15.2/std/#std.Io.Reader.takeDelimiterExclusive

You should be aware that the API accidentally changed between 0.15.1 and 0.15.2

0.15.1:

if (reader.takeDelimiterExclusive('\n')) |line| {
...
} else |err| switch (err) {
  error.EndOfStream => {...},
  else => |e| return e,
}

0.15.2:

if (try reader.takeDelimiter('\n')) |line| {
...
} else {
// end of stream
}

Also read about the whole new Reader and Writer thing.

2 Likes

Firstly, you need to access the interface: reader.interface.

std is wip, and mostly caters to the compilers needs. But you can certainly make a pr to add some convenience functions like this.

for the time being you can do

while (true) {
    const line = line: {
        const l = try reader.interface.takeDelimiterExclusive('\n');
        @memcopy(buffer[0..l.len], l);
        break :line buffer[0..l.len];
    };
}

Keep in mind the unintentionally breaking changes between 0.15.1 and 0.15.2 that @truly-not-taken pointed out.

I think there is a good chance you dont need to copy to the buffer.

1 Like