Begin mocking out for other errors

This commit is contained in:
gingerBill
2024-08-04 11:12:45 +01:00
parent 1826b0c700
commit 7dae38ce89
2 changed files with 46 additions and 19 deletions
+15
View File
@@ -73,6 +73,21 @@ write_encoded_rune :: proc(f: ^File, r: rune) -> (n: int, err: Error) {
return
}
read_at_least :: proc(f: ^File, buf: []byte, min: int) -> (n: int, err: Error) {
if len(buf) < min {
return 0, .Short_Buffer
}
nn := max(int)
for nn > 0 && n < min && err == nil {
nn, err = read(f, buf[n:])
n += nn
}
if n >= min {
err = nil
}
return
}
write_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
return write(f, ([^]byte)(data)[:len])