mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix
This commit is contained in:
@@ -1,16 +1,13 @@
|
|||||||
|
#+build !windows
|
||||||
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) {
|
||||||
temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator })
|
temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator })
|
||||||
|
|
||||||
#partial switch ODIN_OS {
|
#partial switch ODIN_OS {
|
||||||
case .Windows:
|
|
||||||
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 != "" {
|
||||||
@@ -37,9 +34,6 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro
|
|||||||
temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator })
|
temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator })
|
||||||
|
|
||||||
#partial switch ODIN_OS {
|
#partial switch ODIN_OS {
|
||||||
case .Windows:
|
|
||||||
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 != "" {
|
||||||
@@ -63,15 +57,8 @@ 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) {
|
||||||
#partial switch ODIN_OS {
|
if v := get_env("HOME", allocator); v != "" {
|
||||||
case .Windows:
|
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
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,24 @@ package os2
|
|||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
@(require) import win32 "core:sys/windows"
|
@(require) import win32 "core:sys/windows"
|
||||||
|
|
||||||
|
@(require_results)
|
||||||
|
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||||
|
guid := win32.FOLDERID_LocalAppData
|
||||||
|
return _get_known_folder_path(&guid, allocator)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(require_results)
|
||||||
|
user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||||
|
guid := win32.FOLDERID_RoamingAppData
|
||||||
|
return _get_known_folder_path(&guid, allocator)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(require_results)
|
||||||
|
user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||||
|
guid := win32.FOLDERID_Profile
|
||||||
|
return _get_known_folder_path(&guid, allocator)
|
||||||
|
}
|
||||||
|
|
||||||
@(require_results)
|
@(require_results)
|
||||||
_get_known_folder_path :: proc(rfid: win32.REFKNOWNFOLDERID, allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
_get_known_folder_path :: proc(rfid: win32.REFKNOWNFOLDERID, allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath
|
// https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath
|
||||||
|
|||||||
Reference in New Issue
Block a user