mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Get env stuff working on Windows
This commit is contained in:
+10
-12
@@ -5,19 +5,19 @@ import "core:strings"
|
||||
user_cache_dir :: proc(allocator := context.allocator) -> (dir: string, is_defined: bool) {
|
||||
#partial switch ODIN_OS {
|
||||
case .Windows:
|
||||
dir = get_env("LocalAppData")
|
||||
dir = get_env("LocalAppData") or_return
|
||||
if dir != "" {
|
||||
dir = strings.clone(dir, allocator)
|
||||
}
|
||||
case .Darwin:
|
||||
dir = get_env("HOME")
|
||||
dir = get_env("HOME") or_return
|
||||
if dir != "" {
|
||||
dir = strings.concatenate({dir, "/Library/Caches"}, allocator)
|
||||
}
|
||||
case: // All other UNIX systems
|
||||
dir = get_env("XDG_CACHE_HOME")
|
||||
dir = get_env("XDG_CACHE_HOME") or_return
|
||||
if dir == "" {
|
||||
dir = get_env("HOME")
|
||||
dir = get_env("HOME") or_return
|
||||
if dir == "" {
|
||||
return
|
||||
}
|
||||
@@ -31,19 +31,19 @@ user_cache_dir :: proc(allocator := context.allocator) -> (dir: string, is_defin
|
||||
user_config_dir :: proc(allocator := context.allocator) -> (dir: string, is_defined: bool) {
|
||||
#partial switch ODIN_OS {
|
||||
case .Windows:
|
||||
dir = get_env("AppData")
|
||||
dir = get_env("AppData") or_return
|
||||
if dir != "" {
|
||||
dir = strings.clone(dir, allocator)
|
||||
}
|
||||
case .Darwin:
|
||||
dir = get_env("HOME")
|
||||
dir = get_env("HOME") or_return
|
||||
if dir != "" {
|
||||
dir = strings.concatenate({dir, "/Library/Application Support"}, allocator)
|
||||
}
|
||||
case: // All other UNIX systems
|
||||
dir = get_env("XDG_CACHE_HOME")
|
||||
dir = get_env("XDG_CACHE_HOME") or_return
|
||||
if dir == "" {
|
||||
dir = get_env("HOME")
|
||||
dir = get_env("HOME") or_return
|
||||
if dir == "" {
|
||||
return
|
||||
}
|
||||
@@ -60,9 +60,7 @@ user_home_dir :: proc() -> (dir: string, is_defined: bool) {
|
||||
case .Windows:
|
||||
env = "USERPROFILE"
|
||||
}
|
||||
if v := get_env(env); v != "" {
|
||||
return v, true
|
||||
}
|
||||
return "", false
|
||||
v := get_env(env) or_return
|
||||
return v, true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user