Remove all uses of context stuff in os2

This commit is contained in:
gingerBill
2024-05-14 18:34:05 +01:00
parent 450b9ceaec
commit 453fc5182b
7 changed files with 57 additions and 47 deletions
+12 -10
View File
@@ -3,7 +3,6 @@ package os2
import "core:time"
import "base:runtime"
import "core:strings"
import "core:sys/unix"
import "core:path/filepath"
@@ -112,8 +111,9 @@ _fstat_internal :: proc(fd: int, allocator: runtime.Allocator) -> (File_Info, Er
}
// NOTE: _stat and _lstat are using _fstat to avoid a race condition when populating fullpath
_stat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
name_cstr := strings.clone_to_cstring(name, context.temp_allocator)
_stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
TEMP_ALLOCATOR_GUARD()
name_cstr := temp_cstring(name) or_return
fd := unix.sys_open(name_cstr, _O_RDONLY)
if fd < 0 {
@@ -123,8 +123,9 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error)
return _fstat_internal(fd, allocator)
}
_lstat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
name_cstr := strings.clone_to_cstring(name, context.temp_allocator)
_lstat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
TEMP_ALLOCATOR_GUARD()
name_cstr := temp_cstring(name) or_return
fd := unix.sys_open(name_cstr, _O_RDONLY | _O_PATH | _O_NOFOLLOW)
if fd < 0 {
@@ -138,8 +139,9 @@ _same_file :: proc(fi1, fi2: File_Info) -> bool {
return fi1.fullpath == fi2.fullpath
}
_stat_internal :: proc(name: string) -> (s: _Stat, res: int) {
name_cstr := strings.clone_to_cstring(name, context.temp_allocator)
res = unix.sys_stat(name_cstr, &s)
return
}
// _stat_internal :: proc(name: string) -> (s: _Stat, res: int) {
// TEMP_ALLOCATOR_GUARD()
// name_cstr := temp_cstring(name) or_return
// res = unix.sys_stat(name_cstr, &s)
// return
// }