mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fix shutdown/restart commands on Windows.
This commit is contained in:
parent
01923f38e5
commit
fb16dd8a91
|
@ -180,7 +180,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
|||
row.makeAcceptInputHandler([window] {
|
||||
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
|
||||
[] {
|
||||
if(system("sudo shutdown -r now") != 0)
|
||||
if(runRestartCommand() != 0)
|
||||
LOG(LogWarning) << "Restart terminated with non-zero result!";
|
||||
}, "NO", nullptr));
|
||||
});
|
||||
|
@ -191,7 +191,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
|
|||
row.makeAcceptInputHandler([window] {
|
||||
window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES",
|
||||
[] {
|
||||
if(system("sudo shutdown -h now") != 0)
|
||||
if(runShutdownCommand() != 0)
|
||||
LOG(LogWarning) << "Shutdown terminated with non-zero result!";
|
||||
}, "NO", nullptr));
|
||||
});
|
||||
|
|
|
@ -34,3 +34,21 @@ std::string getHomePath()
|
|||
boost::filesystem::path genericPath(homePath);
|
||||
return genericPath.generic_string();
|
||||
}
|
||||
|
||||
int runShutdownCommand()
|
||||
{
|
||||
#ifdef WIN32 // windows
|
||||
return system("shutdown -s -t 0");
|
||||
#else // osx / linux
|
||||
return system("sudo shutdown -h now");
|
||||
#endif
|
||||
}
|
||||
|
||||
int runRestartCommand()
|
||||
{
|
||||
#ifdef WIN32 // windows
|
||||
return system("shutdown -r -t 0");
|
||||
#else // osx / linux
|
||||
return system("sudo shutdown -r now");
|
||||
#endif
|
||||
}
|
|
@ -18,4 +18,6 @@
|
|||
#include <string>
|
||||
|
||||
std::string getHomePath();
|
||||
void setHomePathOverride(const std::string& path);
|
||||
|
||||
int runShutdownCommand(); // shut down the system (returns 0 if successful)
|
||||
int runRestartCommand(); // restart the system (returns 0 if successful)
|
||||
|
|
Loading…
Reference in a new issue