Adds a systemCommand console utility function, which invokes the standard system() function call, and also has an optional callback return parameter.

This commit is contained in:
JeffR 2022-03-15 21:10:55 -05:00
parent 2198dd14d1
commit 1496ffac6e

View file

@ -2859,3 +2859,21 @@ DefineEngineFunction(getTimestamp, const char*, (), ,
return returnBuffer;
}
#ifdef TORQUE_TOOLS
DefineEngineFunction(systemCommand, S32, (const char* commandLineAction, const char* callBackFunction), , "", "")
{
if (commandLineAction != "")
{
S32 result = system(commandLineAction);
if (callBackFunction != "" && callBackFunction[0])
{
if (Con::isFunction(callBackFunction))
Con::executef(callBackFunction, result);
}
}
return -1;
}
#endif