mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
check exec return code for USB mounting
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
14ca315440
commit
5f1db4952f
@ -1,4 +1,5 @@
|
||||
#include "MenuMode.h"
|
||||
#include "../Utility/Utils.h"
|
||||
#include <iostream>
|
||||
#include "../SDL.h"
|
||||
|
||||
@ -882,10 +883,18 @@ void MenuMode::launch( )
|
||||
menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1);
|
||||
|
||||
/// ----- Shell cmd ----
|
||||
fp = popen(usb_mounted?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r");
|
||||
/*fp = popen(usb_mounted?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r");
|
||||
if (fp == NULL) {
|
||||
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
|
||||
}
|
||||
else{
|
||||
usb_mounted = !usb_mounted;
|
||||
}*/
|
||||
|
||||
bool res = Utils::executeRawPath(usb_mounted?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
|
||||
if (!res) {
|
||||
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
|
||||
}
|
||||
else{
|
||||
usb_mounted = !usb_mounted;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <dirent.h>
|
||||
#include <locale>
|
||||
#include <list>
|
||||
@ -267,6 +268,28 @@ std::string Utils::trimEnds(std::string str)
|
||||
return str;
|
||||
}
|
||||
|
||||
bool Utils::executeRawPath(const char *shellCmd)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
Logger::write(Logger::ZONE_INFO, "Utils", "Attempting to launch: " + std::string(shellCmd));
|
||||
|
||||
std::string executionString = "exec " + std::string(shellCmd);
|
||||
printf("Running: %s\n", executionString.c_str());
|
||||
if(system(executionString.c_str()) != 0)
|
||||
{
|
||||
Logger::write(Logger::ZONE_ERROR, "Utils", "Failed to run: " + std::string(shellCmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = true;
|
||||
}
|
||||
|
||||
Logger::write(Logger::ZONE_INFO, "Utils", "Completed");
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int Utils::termfix(uint32_t ttyId){
|
||||
// Init tty file path
|
||||
char ttyFilePath[100];
|
||||
|
||||
@ -44,6 +44,8 @@ public:
|
||||
static std::string combinePath(std::string path1, std::string path2, std::string path3, std::string path4);
|
||||
static std::string combinePath(std::string path1, std::string path2, std::string path3, std::string path4, std::string path5);
|
||||
|
||||
static bool executeRawPath(const char *shellCmd);
|
||||
|
||||
static int termfix(uint32_t ttyId);
|
||||
static int getVTid();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user