mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Fix os.read / os.read_entire_file
- DWORDs are NOT i32 - os.read didn't correctly read as much as it could
This commit is contained in:
+8
-8
@@ -85,13 +85,13 @@ read_entire_file :: proc(name: string) -> (data: []byte, success: bool) {
|
||||
if data == nil {
|
||||
return nil, false;
|
||||
}
|
||||
defer if !success do delete(data);
|
||||
|
||||
bytes_read, read_err := read(fd, data);
|
||||
if read_err != 0 {
|
||||
delete(data);
|
||||
if read_err != ERROR_NONE {
|
||||
return nil, false;
|
||||
}
|
||||
return data[0:bytes_read], true;
|
||||
return data[:bytes_read], true;
|
||||
}
|
||||
|
||||
write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (success: bool) {
|
||||
@@ -100,11 +100,11 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
|
||||
mode: int = 0;
|
||||
when OS == "linux" {
|
||||
// NOTE(justasd): 644 (owner read, write; group read; others read)
|
||||
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
}
|
||||
mode: int = 0;
|
||||
when OS == "linux" {
|
||||
// NOTE(justasd): 644 (owner read, write; group read; others read)
|
||||
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
}
|
||||
|
||||
fd, err := open(name, flags, mode);
|
||||
if err != 0 {
|
||||
|
||||
Reference in New Issue
Block a user