+ if last_error != null then return new Bytes.empty
+ var buf = new Bytes.with_capacity(i)
+ read_intern(i, buf)
+ return buf
+ end
+
+ # Fills `buf` with at most `i` bytes read from `self`
+ private fun read_intern(i: Int, buf: Bytes): Int do
+ if eof then return 0
+ var p = _buffer_pos
+ var bufsp = _buffer_length - p
+ if bufsp >= i then
+ _buffer_pos += i
+ buf.append_ns_from(_buffer, i, p)
+ return i
+ end
+ _buffer_pos = _buffer_length
+ var readln = _buffer_length - p
+ buf.append_ns_from(_buffer, readln, p)
+ var rd = read_intern(i - readln, buf)
+ return rd + readln
+ end
+
+ redef fun read_all_bytes
+ do
+ if last_error != null then return new Bytes.empty
+ var s = new Bytes.with_capacity(10)