ensure that the autostart directories actually exist

This commit is contained in:
EinTim23 2024-11-07 00:27:20 +01:00
parent 0c274c55c5
commit 322ceeaddb
2 changed files with 8 additions and 2 deletions

View File

@ -79,7 +79,10 @@ std::shared_ptr<MediaInfo> backend::getMediaInformation() {
bool backend::toggleAutostart(bool enabled) {
std::filesystem::path launchAgentPath = std::getenv("HOME");
launchAgentPath = launchAgentPath / "Library" / "LaunchAgents" / "PlayerLink.plist";
launchAgentPath = launchAgentPath / "Library" / "LaunchAgents";
std::filesystem::create_directories(launchAgentPath);
launchAgentPath = launchAgentPath / "PlayerLink.plist";
if (!enabled && std::filesystem::exists(launchAgentPath)) {
std::filesystem::remove(launchAgentPath);
return true;

View File

@ -56,7 +56,10 @@ bool CreateShortcut(std::string source, std::string target) {
bool backend::toggleAutostart(bool enabled) {
std::filesystem::path shortcutPath = std::getenv("APPDATA");
shortcutPath = shortcutPath / "Microsoft" / "Windows" / "Start Menu" / "Programs" / "Startup" / "PlayerLink.lnk";
shortcutPath = shortcutPath / "Microsoft" / "Windows" / "Start Menu" / "Programs" / "Startup";
std::filesystem::create_directories(shortcutPath);
shortcutPath = shortcutPath / "PlayerLink.lnk";;
if (!enabled && std::filesystem::exists(shortcutPath)) {
std::filesystem::remove(shortcutPath);
return true;