mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-12-03 19:13:21 -08:00
hook up initial installation detection, in case program is manually installed externally
This commit is contained in:
1 parent
fd33f61a04
commit
eff0827607
3 files changed
+49
-32
No files matched your search
@@ -127,9 +127,10 @@ sh_open_in_browser(String8 url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal B32
|
||||||
sh_install_or_uninstall_self(B32 install)
|
sh_install_or_uninstall_self(B32 write, B32 install)
|
||||||
{
|
{
|
||||||
|
B32 install_state = 0;
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
|
||||||
//- rjf: unpack context
|
//- rjf: unpack context
|
||||||
@@ -159,42 +160,55 @@ sh_install_or_uninstall_self(B32 install)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- rjf: install -> write info
|
//- rjf: if writing -> do mutation
|
||||||
if(install)
|
if(write)
|
||||||
{
|
{
|
||||||
//- rjf: write icon
|
//- rjf: install -> write info
|
||||||
write_data_to_file_path(icon_path, lnx_sh_logo_file_bytes);
|
if(install)
|
||||||
|
{
|
||||||
|
//- rjf: write icon
|
||||||
|
write_data_to_file_path(icon_path, lnx_sh_logo_file_bytes);
|
||||||
|
|
||||||
//- rjf: write .desktop file
|
//- rjf: write .desktop file
|
||||||
String8 desktop_file_data = str8f(scratch.arena,
|
String8 desktop_file_data = str8f(scratch.arena,
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Version=" BUILD_VERSION_STRING_LITERAL "\n"
|
"Version=" BUILD_VERSION_STRING_LITERAL "\n"
|
||||||
"Name=" BUILD_TITLE "\n"
|
"Name=" BUILD_TITLE "\n"
|
||||||
"Comment=" BUILD_TITLE_STRING_LITERAL "\n"
|
"Comment=" BUILD_TITLE_STRING_LITERAL "\n"
|
||||||
"Exec=%S\n"
|
"Exec=%S\n"
|
||||||
"%s%S%s" // (optional icon)
|
"%s%S%s" // (optional icon)
|
||||||
"Terminal=%s\n"
|
"Terminal=%s\n"
|
||||||
"Categories=Utility;Development;",
|
"Categories=Utility;Development;",
|
||||||
get_process_info()->binary_file_path,
|
get_process_info()->binary_file_path,
|
||||||
has_icon ? "Icon=" : "",
|
has_icon ? "Icon=" : "",
|
||||||
has_icon ? icon_path : s(""),
|
has_icon ? icon_path : s(""),
|
||||||
has_icon ? "\n" : "",
|
has_icon ? "\n" : "",
|
||||||
BUILD_CONSOLE_INTERFACE ? "true" : "false");
|
BUILD_CONSOLE_INTERFACE ? "true" : "false");
|
||||||
write_data_to_file_path(desktop_file_path, desktop_file_data);
|
write_data_to_file_path(desktop_file_path, desktop_file_data);
|
||||||
|
|
||||||
//- rjf: make symlink in binary path to this exe
|
//- rjf: make symlink in binary path to this exe
|
||||||
make_directory(str8_chop_last_slash(symlink_path));
|
make_directory(str8_chop_last_slash(symlink_path));
|
||||||
symlink((char *)get_process_info()->binary_file_path.str, (char *)symlink_path.str);
|
symlink((char *)get_process_info()->binary_file_path.str, (char *)symlink_path.str);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- rjf: uninstall -> delete files
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete_file_at_path(icon_path);
|
||||||
|
delete_file_at_path(desktop_file_path);
|
||||||
|
unlink((char *)symlink_path.str);
|
||||||
|
}
|
||||||
|
|
||||||
|
install_state = install;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: uninstall -> delete files
|
//- rjf: do reading -> check if installation state exists
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete_file_at_path(icon_path);
|
install_state = file_path_exists(desktop_file_path);
|
||||||
delete_file_at_path(desktop_file_path);
|
|
||||||
unlink((char *)symlink_path.str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
|
return install_state;
|
||||||
}
|
}
|
||||||
@@ -11486,6 +11486,9 @@ rd_init(CmdLine *cmdln)
|
|||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rjf: check initial installation status
|
||||||
|
rd_state->installed = sh_install_or_uninstall_self(0, 0);
|
||||||
|
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
@@ -13208,7 +13211,7 @@ rd_frame(void)
|
|||||||
B32 last_installed = rd_state->installed;
|
B32 last_installed = rd_state->installed;
|
||||||
if(installed != last_installed)
|
if(installed != last_installed)
|
||||||
{
|
{
|
||||||
sh_install_or_uninstall_self(installed);
|
sh_install_or_uninstall_self(1, installed);
|
||||||
rd_state->installed = installed;
|
rd_state->installed = installed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,6 +11,6 @@ internal void sh_message(B32 error, String8 title, String8 message);
|
|||||||
internal String8 sh_pick_file(Arena *arena, String8 title, String8 initial_path);
|
internal String8 sh_pick_file(Arena *arena, String8 title, String8 initial_path);
|
||||||
internal void sh_show_in_file_browser(String8 path);
|
internal void sh_show_in_file_browser(String8 path);
|
||||||
internal void sh_open_in_browser(String8 url);
|
internal void sh_open_in_browser(String8 url);
|
||||||
internal void sh_install_or_uninstall_self(B32 install);
|
internal B32 sh_install_or_uninstall_self(B32 write, B32 install);
|
||||||
|
|
||||||
#endif // SHELL_H
|
#endif // SHELL_H
|
||||||
Reference in new issue
Block a user