I’ve been looking for a way to process files for the past two days.
The core:os library has os.open (not to mention that one of the errors involves an enum with nearly 3,000 values idk why), which returns ^os.File.
To avoid overloading my computer with a large file, I wanted to use streaming. Since odin is syntactically similar to go, I checked out os.bufio.
The documentation didn’t include information on how to use this package, and there are only brief descriptions, so I started reviewing the package’s code (core:bufio and core:io).
To create a bufio.Reader (bufio.reader_init), I need an io.Reader; in the io package, io.Reader is an alias for Stream:
Stream_Proc :: #type proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error)
Stream :: struct {
procedure: Stream_Proc,
data: rawptr,
}
I’ve gone through the entire core.io package, but I can’t find a function anywhere to create a stream from os.File. There are conversion functions, but they only cover types within the package.
Am I looking in the wrong place, or should I just implement this myself, or should I do it the C way instead (using getchar with a pointer to a file + a buffer)?