|
@@ -1,6 +1,7 @@
|
|
package os2
|
|
package os2
|
|
|
|
|
|
import "base:runtime"
|
|
import "base:runtime"
|
|
|
|
+@(require) import win32 "core:sys/windows"
|
|
|
|
|
|
@(require_results)
|
|
@(require_results)
|
|
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
|
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
|
@@ -8,10 +9,8 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error
|
|
|
|
|
|
#partial switch ODIN_OS {
|
|
#partial switch ODIN_OS {
|
|
case .Windows:
|
|
case .Windows:
|
|
- dir = get_env("LocalAppData", temp_allocator)
|
|
|
|
- if dir != "" {
|
|
|
|
- dir = clone_string(dir, allocator) or_return
|
|
|
|
- }
|
|
|
|
|
|
+ guid := win32.FOLDERID_LocalAppData
|
|
|
|
+ return _get_known_folder_path(&guid, allocator)
|
|
case .Darwin:
|
|
case .Darwin:
|
|
dir = get_env("HOME", temp_allocator)
|
|
dir = get_env("HOME", temp_allocator)
|
|
if dir != "" {
|
|
if dir != "" {
|
|
@@ -39,10 +38,8 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro
|
|
|
|
|
|
#partial switch ODIN_OS {
|
|
#partial switch ODIN_OS {
|
|
case .Windows:
|
|
case .Windows:
|
|
- dir = get_env("AppData", temp_allocator)
|
|
|
|
- if dir != "" {
|
|
|
|
- dir = clone_string(dir, allocator) or_return
|
|
|
|
- }
|
|
|
|
|
|
+ guid := win32.FOLDERID_RoamingAppData
|
|
|
|
+ return _get_known_folder_path(&guid, allocator)
|
|
case .Darwin:
|
|
case .Darwin:
|
|
dir = get_env("HOME", temp_allocator)
|
|
dir = get_env("HOME", temp_allocator)
|
|
if dir != "" {
|
|
if dir != "" {
|
|
@@ -66,14 +63,15 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro
|
|
|
|
|
|
@(require_results)
|
|
@(require_results)
|
|
user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
|
user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
|
- env := "HOME"
|
|
|
|
#partial switch ODIN_OS {
|
|
#partial switch ODIN_OS {
|
|
case .Windows:
|
|
case .Windows:
|
|
- env = "USERPROFILE"
|
|
|
|
- }
|
|
|
|
- if v := get_env(env, allocator); v != "" {
|
|
|
|
- return v, nil
|
|
|
|
|
|
+ guid := win32.FOLDERID_Profile
|
|
|
|
+ return _get_known_folder_path(&guid, allocator)
|
|
|
|
+ case:
|
|
|
|
+ if v := get_env("HOME", allocator); v != "" {
|
|
|
|
+ return v, nil
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
return "", .Invalid_Path
|
|
return "", .Invalid_Path
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
+}
|