mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
os2: Resolve temp allocator collisions
This commit is contained in:
+11
-11
@@ -4,27 +4,27 @@ import "base:runtime"
|
||||
|
||||
@(require_results)
|
||||
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({ allocator }))
|
||||
|
||||
#partial switch ODIN_OS {
|
||||
case .Windows:
|
||||
dir = get_env("LocalAppData", temp_allocator())
|
||||
dir = get_env("LocalAppData", temp_allocator)
|
||||
if dir != "" {
|
||||
dir = clone_string(dir, allocator) or_return
|
||||
dir = clone_string(dir, temp_allocator) or_return
|
||||
}
|
||||
case .Darwin:
|
||||
dir = get_env("HOME", temp_allocator())
|
||||
dir = get_env("HOME", temp_allocator)
|
||||
if dir != "" {
|
||||
dir = concatenate({dir, "/Library/Caches"}, allocator) or_return
|
||||
dir = concatenate({dir, "/Library/Caches"}, temp_allocator) or_return
|
||||
}
|
||||
case: // All other UNIX systems
|
||||
dir = get_env("XDG_CACHE_HOME", allocator)
|
||||
if dir == "" {
|
||||
dir = get_env("HOME", temp_allocator())
|
||||
dir = get_env("HOME", temp_allocator)
|
||||
if dir == "" {
|
||||
return
|
||||
}
|
||||
dir = concatenate({dir, "/.cache"}, allocator) or_return
|
||||
dir = concatenate({dir, "/.cache"}, temp_allocator) or_return
|
||||
}
|
||||
}
|
||||
if dir == "" {
|
||||
@@ -35,23 +35,23 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error
|
||||
|
||||
@(require_results)
|
||||
user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
TEMP_ALLOCATOR_GUARD()
|
||||
temp_allocator := get_temp_allocator(TEMP_ALLOCATOR_GUARD({ allocator }))
|
||||
|
||||
#partial switch ODIN_OS {
|
||||
case .Windows:
|
||||
dir = get_env("AppData", temp_allocator())
|
||||
dir = get_env("AppData", temp_allocator)
|
||||
if dir != "" {
|
||||
dir = clone_string(dir, allocator) or_return
|
||||
}
|
||||
case .Darwin:
|
||||
dir = get_env("HOME", temp_allocator())
|
||||
dir = get_env("HOME", temp_allocator)
|
||||
if dir != "" {
|
||||
dir = concatenate({dir, "/.config"}, allocator) or_return
|
||||
}
|
||||
case: // All other UNIX systems
|
||||
dir = get_env("XDG_CONFIG_HOME", allocator)
|
||||
if dir == "" {
|
||||
dir = get_env("HOME", temp_allocator())
|
||||
dir = get_env("HOME", temp_allocator)
|
||||
if dir == "" {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user