mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Expect stream as a field directly on os2.File
This commit is contained in:
@@ -6,6 +6,7 @@ import "base:runtime"
|
||||
|
||||
File :: struct {
|
||||
impl: _File,
|
||||
stream: io.Stream,
|
||||
}
|
||||
|
||||
File_Mode :: distinct u32
|
||||
@@ -72,56 +73,56 @@ name :: proc(f: ^File) -> string {
|
||||
|
||||
close :: proc(f: ^File) -> Error {
|
||||
if f != nil {
|
||||
return io.close(f.impl.stream)
|
||||
return io.close(f.stream)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
seek :: proc(f: ^File, offset: i64, whence: io.Seek_From) -> (ret: i64, err: Error) {
|
||||
if f != nil {
|
||||
return io.seek(f.impl.stream, offset, whence)
|
||||
return io.seek(f.stream, offset, whence)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) {
|
||||
if f != nil {
|
||||
return io.read(f.impl.stream, p)
|
||||
return io.read(f.stream, p)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) {
|
||||
if f != nil {
|
||||
return io.read_at(f.impl.stream, p, offset)
|
||||
return io.read_at(f.stream, p, offset)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
write :: proc(f: ^File, p: []byte) -> (n: int, err: Error) {
|
||||
if f != nil {
|
||||
return io.write(f.impl.stream, p)
|
||||
return io.write(f.stream, p)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) {
|
||||
if f != nil {
|
||||
return io.write_at(f.impl.stream, p, offset)
|
||||
return io.write_at(f.stream, p, offset)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
file_size :: proc(f: ^File) -> (n: i64, err: Error) {
|
||||
if f != nil {
|
||||
return io.size(f.impl.stream)
|
||||
return io.size(f.stream)
|
||||
}
|
||||
return 0, .Invalid_File
|
||||
}
|
||||
|
||||
flush :: proc(f: ^File) -> Error {
|
||||
if f != nil {
|
||||
return io.flush(f.impl.stream)
|
||||
return io.flush(f.stream)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user