mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
add more user dirs
This commit is contained in:
@@ -3,25 +3,60 @@ package os2
|
||||
import "base:runtime"
|
||||
@(require) import win32 "core:sys/windows"
|
||||
|
||||
@(require_results)
|
||||
user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
_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) {
|
||||
_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) {
|
||||
_user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Profile
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
_user_data_dir :: _user_config_dir
|
||||
|
||||
_user_state_dir :: _user_cache_dir
|
||||
|
||||
_user_music_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Music
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_desktop_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Desktop
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_documents_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Documents
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_downloads_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Downloads
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_pictures_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Pictures
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_public_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Public
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_user_videos_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
|
||||
guid := win32.FOLDERID_Videos
|
||||
return _get_known_folder_path(&guid, allocator)
|
||||
}
|
||||
|
||||
_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
|
||||
// See also `known_folders.odin` in `core:sys/windows` for the GUIDs.
|
||||
|
||||
Reference in New Issue
Block a user