mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Add hidden __tag for union variables.
This commit is contained in:
+36
-2
@@ -1,3 +1,37 @@
|
||||
#load "os_windows.odin" when ODIN_OS == "windows";
|
||||
#load "os_x.odin" when ODIN_OS == "osx";
|
||||
#load "os_linux.odin" when ODIN_OS == "linux";
|
||||
#load "os_x.odin" when ODIN_OS == "osx";
|
||||
#load "os_linux.odin" when ODIN_OS == "linux";
|
||||
|
||||
write_string :: proc(fd: Handle, str: string) -> (int, Errno) {
|
||||
return write(fd, []byte(str));
|
||||
}
|
||||
|
||||
read_entire_file :: proc(name: string) -> ([]byte, bool) {
|
||||
fd, err := open(name, O_RDONLY, 0);
|
||||
if err != ERROR_NONE {
|
||||
return nil, false;
|
||||
}
|
||||
defer close(fd);
|
||||
|
||||
length: i64;
|
||||
if length, err = file_size(fd); err != ERROR_NONE {
|
||||
return nil, false;
|
||||
}
|
||||
|
||||
if length == 0 {
|
||||
return nil, true;
|
||||
}
|
||||
|
||||
data := make([]byte, length);
|
||||
if data == nil {
|
||||
return nil, false;
|
||||
}
|
||||
|
||||
bytes_read, read_err := read(fd, data);
|
||||
if read_err != ERROR_NONE {
|
||||
free(data);
|
||||
return nil, false;
|
||||
}
|
||||
return data[0..<bytes_read], true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user