mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(!is_temp(allocator))
|
||||||
TEMP_ALLOCATOR_GUARD()
|
TEMP_ALLOCATOR_GUARD()
|
||||||
|
|
||||||
for !it.impl.no_more_files {
|
for !it.impl.no_more_files {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
|||||||
if key == "" {
|
if key == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
assert(!is_temp(allocator))
|
||||||
TEMP_ALLOCATOR_GUARD()
|
TEMP_ALLOCATOR_GUARD()
|
||||||
wkey, _ := win32_utf8_to_wstring(key, temp_allocator())
|
wkey, _ := win32_utf8_to_wstring(key, temp_allocator())
|
||||||
|
|
||||||
@@ -20,8 +21,6 @@ _lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string
|
|||||||
return "", true
|
return "", true
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_ALLOCATOR_GUARD()
|
|
||||||
|
|
||||||
b := make([]u16, n+1, temp_allocator())
|
b := make([]u16, n+1, temp_allocator())
|
||||||
|
|
||||||
n = win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b)))
|
n = win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b)))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package os2
|
package os2
|
||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
|
|
||||||
import "core:path/filepath"
|
import "core:path/filepath"
|
||||||
import "core:sys/posix"
|
import "core:sys/posix"
|
||||||
import "core:time"
|
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
|
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) {
|
_stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
err = .Invalid_Path
|
err = .Invalid_Path
|
||||||
@@ -75,6 +75,11 @@ _stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err
|
|||||||
cname := temp_cstring(name) or_return
|
cname := temp_cstring(name) or_return
|
||||||
|
|
||||||
rcname := posix.realpath(cname)
|
rcname := posix.realpath(cname)
|
||||||
|
if rcname == nil {
|
||||||
|
err = .Invalid_Path
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer posix.free(rcname)
|
||||||
|
|
||||||
stat: posix.stat_t
|
stat: posix.stat_t
|
||||||
if posix.stat(rcname, &stat) != .OK {
|
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
|
cname := temp_cstring(name) or_return
|
||||||
|
|
||||||
rcname := posix.realpath(cname)
|
rcname := posix.realpath(cname)
|
||||||
|
if rcname == nil {
|
||||||
|
err = .Invalid_Path
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer posix.free(rcname)
|
||||||
|
|
||||||
stat: posix.stat_t
|
stat: posix.stat_t
|
||||||
if posix.lstat(rcname, &stat) != .OK {
|
if posix.lstat(rcname, &stat) != .OK {
|
||||||
|
|||||||
Reference in New Issue
Block a user