From a1759aa2fafcb000359436d967d58a67a9b1a782 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 5 Jun 2025 16:54:39 +0200 Subject: [PATCH] Fix --- core/os/os2/{user.odin => user_posix.odin} | 19 +++---------------- core/os/os2/user_windows.odin | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) rename core/os/os2/{user.odin => user_posix.odin} (75%) diff --git a/core/os/os2/user.odin b/core/os/os2/user_posix.odin similarity index 75% rename from core/os/os2/user.odin rename to core/os/os2/user_posix.odin index 83dc564ac..c49d51bb3 100644 --- a/core/os/os2/user.odin +++ b/core/os/os2/user_posix.odin @@ -1,16 +1,13 @@ +#+build !windows package os2 import "base:runtime" -@(require) import win32 "core:sys/windows" @(require_results) user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) { temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator }) #partial switch ODIN_OS { - case .Windows: - guid := win32.FOLDERID_LocalAppData - return _get_known_folder_path(&guid, allocator) case .Darwin: dir = get_env("HOME", temp_allocator) if dir != "" { @@ -37,9 +34,6 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro temp_allocator := TEMP_ALLOCATOR_GUARD({ allocator }) #partial switch ODIN_OS { - case .Windows: - guid := win32.FOLDERID_RoamingAppData - return _get_known_folder_path(&guid, allocator) case .Darwin: dir = get_env("HOME", temp_allocator) if dir != "" { @@ -63,15 +57,8 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro @(require_results) user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) { - #partial switch ODIN_OS { - case .Windows: - guid := win32.FOLDERID_Profile - return _get_known_folder_path(&guid, allocator) - case: - if v := get_env("HOME", allocator); v != "" { - return v, nil - } - + if v := get_env("HOME", allocator); v != "" { + return v, nil } return "", .Invalid_Path } \ No newline at end of file diff --git a/core/os/os2/user_windows.odin b/core/os/os2/user_windows.odin index 6aef6cb4a..fd007af03 100644 --- a/core/os/os2/user_windows.odin +++ b/core/os/os2/user_windows.odin @@ -3,6 +3,24 @@ package os2 import "base:runtime" @(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) _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