mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Bridged a bugfix from os_windows to other os's.
This commit is contained in:
+4
-4
@@ -83,7 +83,7 @@ close :: proc(fd: Handle) {
|
|||||||
write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
bytes_written := unix_write(fd, data.data, data.count);
|
bytes_written := unix_write(fd, ^data[0], len(data));
|
||||||
if(bytes_written == -1) {
|
if(bytes_written == -1) {
|
||||||
return 0, 1;
|
return 0, 1;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
|||||||
read :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
read :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
bytes_read := unix_read(fd, data.data, data.count);
|
bytes_read := unix_read(fd, ^data[0], len(data));
|
||||||
if(bytes_read == -1) {
|
if(bytes_read == -1) {
|
||||||
return 0, 1;
|
return 0, 1;
|
||||||
}
|
}
|
||||||
@@ -147,8 +147,8 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
|
|||||||
|
|
||||||
// We have a file size!
|
// We have a file size!
|
||||||
|
|
||||||
data := new_slice(u8, size+1);
|
data := make([]u8, size+1);
|
||||||
if data.data == nil {
|
if data == nil {
|
||||||
fmt.println("Failed to allocate file buffer.");
|
fmt.println("Failed to allocate file buffer.");
|
||||||
return nil, false;
|
return nil, false;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -87,7 +87,7 @@ close :: proc(fd: Handle) {
|
|||||||
write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
bytes_written := unix_write(fd, data.data, data.count);
|
bytes_written := unix_write(fd, ^data[0], len(data));
|
||||||
if(bytes_written == -1) {
|
if(bytes_written == -1) {
|
||||||
return 0, 1;
|
return 0, 1;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ write :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
|||||||
read :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
read :: proc(fd: Handle, data: []byte) -> (AddressSize, Errno) {
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
bytes_read := unix_read(fd, data.data, data.count);
|
bytes_read := unix_read(fd, ^data[0], len(data));
|
||||||
if(bytes_read == -1) {
|
if(bytes_read == -1) {
|
||||||
return 0, 1;
|
return 0, 1;
|
||||||
}
|
}
|
||||||
@@ -151,8 +151,8 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
|
|||||||
|
|
||||||
// We have a file size!
|
// We have a file size!
|
||||||
|
|
||||||
data := new_slice(u8, size+1);
|
data := make([]u8, size+1);
|
||||||
if data.data == nil {
|
if ^data[0] == nil {
|
||||||
fmt.println("Failed to allocate file buffer.");
|
fmt.println("Failed to allocate file buffer.");
|
||||||
return nil, false;
|
return nil, false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user