[ui] Add auto-mount on first launch functionality #52

This commit is contained in:
2025-09-06 18:42:51 -05:00
parent 9ce49848fd
commit 06ae4bab43
3 changed files with 13 additions and 0 deletions

View File

@@ -247,6 +247,7 @@ void mgmt_app_config::set_auto_start(bool auto_start) {
utils::shortcut_cfg cfg{};
cfg.arguments = {L"-ui", L"-lo"};
cfg.exe_path = utils::path::combine(L".", {L"repertory"});
cfg.icon_path = utils::path::combine(".", {"icon.ico"});
cfg.location = utils::path::absolute(L".");
cfg.shortcut_name = L"repertory";
if (utils::create_shortcut(cfg, false)) {

View File

@@ -45,6 +45,7 @@ void free_console();
struct shortcut_cfg final {
std::wstring arguments;
std::wstring exe_path;
std::wstring icon_path;
std::wstring location{get_startup_folder()};
std::wstring shortcut_name;
std::wstring working_directory;

View File

@@ -242,6 +242,17 @@ auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool {
return false;
}
if (not cfg.icon_path.empty()) {
result = psl->SetIconLocation(cfg.icon_path.c_str(), 0);
if (FAILED(result)) {
utils::error::handle_error(
function_name,
std::string("IShellLink::SetIconLocation failed: ") + hr_hex(result));
psl->Release();
return false;
}
}
if (not utils::file::file{lnk_path}.remove()) {
utils::error::handle_error(function_name,
"failed to remove existing shortcut|path|" +