mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-16 08:04:07 +00:00
os2: cleanup
This commit is contained in:
@@ -57,6 +57,7 @@ _read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info
|
||||
return
|
||||
}
|
||||
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
|
||||
for !it.impl.no_more_files {
|
||||
|
||||
@@ -8,6 +8,7 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
||||
if key == "" {
|
||||
return
|
||||
}
|
||||
assert(!is_temp(allocator))
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
wkey, _ := win32_utf8_to_wstring(key, temp_allocator())
|
||||
|
||||
@@ -20,8 +21,6 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
||||
return "", true
|
||||
}
|
||||
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
|
||||
b := make([]u16, n+1, temp_allocator())
|
||||
|
||||
n = win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b)))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package os2
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
import "core:path/filepath"
|
||||
import "core:sys/posix"
|
||||
import "core:time"
|
||||
@@ -63,7 +64,6 @@ _fstat :: proc(f: ^File, allocator: runtime.Allocator) -> (fi: File_Info, err: E
|
||||
return internal_stat(stat, fullpath), nil
|
||||
}
|
||||
|
||||
// NOTE: _stat and _lstat are using _fstat to avoid a race condition when populating fullpath
|
||||
_stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
|
||||
if name == "" {
|
||||
err = .Invalid_Path
|
||||
@@ -75,6 +75,11 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err
|
||||
cname := temp_cstring(name) or_return
|
||||
|
||||
rcname := posix.realpath(cname)
|
||||
if rcname == nil {
|
||||
err = .Invalid_Path
|
||||
return
|
||||
}
|
||||
defer posix.free(rcname)
|
||||
|
||||
stat: posix.stat_t
|
||||
if posix.stat(rcname, &stat) != .OK {
|
||||
@@ -97,6 +102,11 @@ _lstat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, er
|
||||
cname := temp_cstring(name) or_return
|
||||
|
||||
rcname := posix.realpath(cname)
|
||||
if rcname == nil {
|
||||
err = .Invalid_Path
|
||||
return
|
||||
}
|
||||
defer posix.free(rcname)
|
||||
|
||||
stat: posix.stat_t
|
||||
if posix.lstat(rcname, &stat) != .OK {
|
||||
|
||||
Reference in New Issue
Block a user