mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
os2: Resolve temp allocator collisions
This commit is contained in:
@@ -69,8 +69,8 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err
|
||||
return
|
||||
}
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
cname := temp_cstring(name) or_return
|
||||
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({ allocator }))
|
||||
cname := clone_to_cstring(name, temp_allocator) or_return
|
||||
|
||||
fd := posix.open(cname, {})
|
||||
if fd == -1 {
|
||||
@@ -96,33 +96,33 @@ _lstat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, er
|
||||
return
|
||||
}
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({ allocator }))
|
||||
|
||||
// NOTE: can't use realpath or open (+ fcntl F_GETPATH) here because it tries to resolve symlinks.
|
||||
|
||||
// NOTE: This might not be correct when given "/symlink/foo.txt",
|
||||
// you would want that to resolve "/symlink", but not resolve "foo.txt".
|
||||
|
||||
fullpath := clean_path(name, temp_allocator()) or_return
|
||||
fullpath := clean_path(name, temp_allocator) or_return
|
||||
assert(len(fullpath) > 0)
|
||||
switch {
|
||||
case fullpath[0] == '/':
|
||||
// nothing.
|
||||
case fullpath == ".":
|
||||
fullpath = getwd(temp_allocator()) or_return
|
||||
fullpath = getwd(temp_allocator) or_return
|
||||
case len(fullpath) > 1 && fullpath[0] == '.' && fullpath[1] == '/':
|
||||
fullpath = fullpath[2:]
|
||||
fallthrough
|
||||
case:
|
||||
fullpath = concatenate({
|
||||
getwd(temp_allocator()) or_return,
|
||||
getwd(temp_allocator) or_return,
|
||||
"/",
|
||||
fullpath,
|
||||
}, temp_allocator()) or_return
|
||||
}, temp_allocator) or_return
|
||||
}
|
||||
|
||||
stat: posix.stat_t
|
||||
if posix.lstat(temp_cstring(fullpath), &stat) != .OK {
|
||||
if posix.lstat(clone_to_cstring(fullpath), &stat, temp_allocator) != .OK {
|
||||
err = _get_platform_error()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user