Merge pull request #741 from Areloch/systemCommandFunction

Adds a systemCommand console utility function
This commit is contained in:
Brian Roberts 2022-03-16 03:30:33 -05:00 committed by GitHub
commit dad0149dfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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