mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Minor improvements to io and os
This commit is contained in:
+2
-7
@@ -4,7 +4,6 @@
|
|||||||
package io
|
package io
|
||||||
|
|
||||||
import "core:intrinsics"
|
import "core:intrinsics"
|
||||||
import "core:runtime"
|
|
||||||
import "core:unicode/utf8"
|
import "core:unicode/utf8"
|
||||||
|
|
||||||
// Seek whence values
|
// Seek whence values
|
||||||
@@ -254,11 +253,7 @@ read_at :: proc(r: Reader_At, p: []byte, offset: i64, n_read: ^int = nil) -> (n:
|
|||||||
return 0, .Empty
|
return 0, .Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_offset: i64
|
curr_offset := r->impl_seek(offset, .Current) or_return
|
||||||
curr_offset, err = r->impl_seek(offset, .Current)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
n, err = r->impl_read(p)
|
n, err = r->impl_read(p)
|
||||||
_, err1 := r->impl_seek(curr_offset, .Start)
|
_, err1 := r->impl_seek(curr_offset, .Start)
|
||||||
@@ -552,7 +547,7 @@ _copy_buffer :: proc(dst: Writer, src: Reader, buf: []byte) -> (written: i64, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE(bill): alloca is fine here
|
// NOTE(bill): alloca is fine here
|
||||||
buf = transmute([]byte)runtime.Raw_Slice{intrinsics.alloca(size, 2*align_of(rawptr)), size}
|
buf = intrinsics.alloca(size, 2*align_of(rawptr))[:size]
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
nr, er := read(src, buf)
|
nr, er := read(src, buf)
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ OS :: ODIN_OS
|
|||||||
ARCH :: ODIN_ARCH
|
ARCH :: ODIN_ARCH
|
||||||
ENDIAN :: ODIN_ENDIAN
|
ENDIAN :: ODIN_ENDIAN
|
||||||
|
|
||||||
|
SEEK_SET :: 0
|
||||||
|
SEEK_CUR :: 1
|
||||||
|
SEEK_END :: 2
|
||||||
|
|
||||||
write_string :: proc(fd: Handle, str: string) -> (int, Errno) {
|
write_string :: proc(fd: Handle, str: string) -> (int, Errno) {
|
||||||
return write(fd, transmute([]byte)str)
|
return write(fd, transmute([]byte)str)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,9 +163,6 @@ O_SYNC :: 0x0080
|
|||||||
O_ASYNC :: 0x0040
|
O_ASYNC :: 0x0040
|
||||||
O_CLOEXEC :: 0x1000000
|
O_CLOEXEC :: 0x1000000
|
||||||
|
|
||||||
SEEK_SET :: 0
|
|
||||||
SEEK_CUR :: 1
|
|
||||||
SEEK_END :: 2
|
|
||||||
SEEK_DATA :: 3
|
SEEK_DATA :: 3
|
||||||
SEEK_HOLE :: 4
|
SEEK_HOLE :: 4
|
||||||
SEEK_MAX :: SEEK_HOLE
|
SEEK_MAX :: SEEK_HOLE
|
||||||
|
|||||||
@@ -123,9 +123,6 @@ O_ASYNC :: 0x02000
|
|||||||
O_CLOEXEC :: 0x80000
|
O_CLOEXEC :: 0x80000
|
||||||
|
|
||||||
|
|
||||||
SEEK_SET :: 0
|
|
||||||
SEEK_CUR :: 1
|
|
||||||
SEEK_END :: 2
|
|
||||||
SEEK_DATA :: 3
|
SEEK_DATA :: 3
|
||||||
SEEK_HOLE :: 4
|
SEEK_HOLE :: 4
|
||||||
SEEK_MAX :: SEEK_HOLE
|
SEEK_MAX :: SEEK_HOLE
|
||||||
|
|||||||
@@ -167,9 +167,6 @@ O_ASYNC :: 0x02000
|
|||||||
O_CLOEXEC :: 0x80000
|
O_CLOEXEC :: 0x80000
|
||||||
|
|
||||||
|
|
||||||
SEEK_SET :: 0
|
|
||||||
SEEK_CUR :: 1
|
|
||||||
SEEK_END :: 2
|
|
||||||
SEEK_DATA :: 3
|
SEEK_DATA :: 3
|
||||||
SEEK_HOLE :: 4
|
SEEK_HOLE :: 4
|
||||||
SEEK_MAX :: SEEK_HOLE
|
SEEK_MAX :: SEEK_HOLE
|
||||||
|
|||||||
@@ -125,10 +125,6 @@ O_EXCL :: 0x00800
|
|||||||
O_NOCTTY :: 0x08000
|
O_NOCTTY :: 0x08000
|
||||||
O_CLOEXEC :: 0x10000
|
O_CLOEXEC :: 0x10000
|
||||||
|
|
||||||
SEEK_SET :: 0
|
|
||||||
SEEK_CUR :: 1
|
|
||||||
SEEK_END :: 2
|
|
||||||
|
|
||||||
RTLD_LAZY :: 0x001
|
RTLD_LAZY :: 0x001
|
||||||
RTLD_NOW :: 0x002
|
RTLD_NOW :: 0x002
|
||||||
RTLD_LOCAL :: 0x000
|
RTLD_LOCAL :: 0x000
|
||||||
|
|||||||
Reference in New Issue
Block a user