ensure that the autostart directories actually exist
This commit is contained in:
parent
0c274c55c5
commit
322ceeaddb
|
@ -79,7 +79,10 @@ std::shared_ptr<MediaInfo> backend::getMediaInformation() {
|
||||||
|
|
||||||
bool backend::toggleAutostart(bool enabled) {
|
bool backend::toggleAutostart(bool enabled) {
|
||||||
std::filesystem::path launchAgentPath = std::getenv("HOME");
|
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)) {
|
if (!enabled && std::filesystem::exists(launchAgentPath)) {
|
||||||
std::filesystem::remove(launchAgentPath);
|
std::filesystem::remove(launchAgentPath);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -56,7 +56,10 @@ bool CreateShortcut(std::string source, std::string target) {
|
||||||
|
|
||||||
bool backend::toggleAutostart(bool enabled) {
|
bool backend::toggleAutostart(bool enabled) {
|
||||||
std::filesystem::path shortcutPath = std::getenv("APPDATA");
|
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)) {
|
if (!enabled && std::filesystem::exists(shortcutPath)) {
|
||||||
std::filesystem::remove(shortcutPath);
|
std::filesystem::remove(shortcutPath);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue