Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/platform/windows.jai
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,24 @@ platform_get_fonts_dir :: () -> string {
}

platform_open_in_explorer :: (path: string, reveal := false) {
path_backslashes := copy_string(path,, allocator = temp);
path_overwrite_separators(path_backslashes, #char "\\");

if reveal run_command("explorer", "/select,", path_backslashes);
else run_command("explorer", path_backslashes);
ITEMIDLIST :: struct {}
ShellExecuteW :: (hwnd: HWND, lpOperation: *u16, lpFile: *u16, lpParameters: *u16, lpDirectory: *u16, nShowCmd: s32) -> HINSTANCE #foreign shell32;
ILCreateFromPathW :: (pszPath: *u16) -> *ITEMIDLIST #foreign shell32;
ILFree :: (pidl: *ITEMIDLIST) -> void #foreign shell32;
SHOpenFolderAndSelectItems :: (pidlFolder: *ITEMIDLIST, cidl: u32, apidl: **ITEMIDLIST, dwFlags: u32) -> HRESULT #foreign shell32;

path_wide := utf8_to_wide(path,, temp);

if reveal {
pidl := ILCreateFromPathW(path_wide);
if pidl {
SHOpenFolderAndSelectItems(pidl, 0, null, 0);
ILFree(pidl);
}
} else {
verb_wide := utf8_to_wide("open",, temp);
ShellExecuteW(null, verb_wide, path_wide, null, null, 1);
}
}

platform_path_equals :: inline (path_a: string, path_b: string) -> bool {
Expand Down