Odin icon indicating copy to clipboard operation
Odin copied to clipboard

[core:os] os.Stream does not return read errors

Open kleeon opened this issue 2 years ago • 0 comments

I'm having problems with the following code:

package main

import "core:bytes"
import "core:os"
import "core:io"

main :: proc() {
  buf: bytes.Buffer
  fh, _ := os.open("test.txt")
  s := os.stream_from_handle(fh)
  rd, _ := io.to_reader(s)

  bytes.buffer_read_from(&buf, rd)
}

buffer_read_from has a loop that uses an error check as it's escape condition, however os.Stream ignores all errors so the loop hangs the program. It would be very convenient to have buffer_read_from working properly.

kleeon avatar Oct 25 '22 15:10 kleeon