2018-01-30 00:49:08 +00:00
|
|
|
#include "Scripting.h"
|
|
|
|
#include "Log.h"
|
2020-06-21 10:26:21 +00:00
|
|
|
#include "Platform.h"
|
2018-01-30 00:49:08 +00:00
|
|
|
#include "utils/FileSystemUtil.h"
|
|
|
|
|
|
|
|
namespace Scripting
|
|
|
|
{
|
|
|
|
void fireEvent(const std::string& eventName, const std::string& arg1, const std::string& arg2)
|
|
|
|
{
|
|
|
|
LOG(LogDebug) << "fireEvent: " << eventName << " " << arg1 << " " << arg2;
|
|
|
|
|
|
|
|
std::list<std::string> scriptDirList;
|
|
|
|
std::string test;
|
|
|
|
|
|
|
|
// check in exepath
|
|
|
|
test = Utils::FileSystem::getExePath() + "/scripts/" + eventName;
|
|
|
|
if(Utils::FileSystem::exists(test))
|
|
|
|
scriptDirList.push_back(test);
|
|
|
|
|
|
|
|
// check in homepath
|
|
|
|
test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName;
|
|
|
|
if(Utils::FileSystem::exists(test))
|
|
|
|
scriptDirList.push_back(test);
|
|
|
|
|
|
|
|
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
|
|
|
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
|
|
|
for (std::list<std::string>::const_iterator it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
|
|
|
// append folder to path
|
|
|
|
std::string script = *it + " \"" + arg1 + "\" \"" + arg2 + "\"";
|
|
|
|
LOG(LogDebug) << " executing: " << script;
|
|
|
|
runSystemCommand(script);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Scripting::
|