Browse Source

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

JeffR 3 years ago
parent
commit
1496ffac6e
1 changed files with 18 additions and 0 deletions
  1. 18 0
      Engine/source/console/consoleFunctions.cpp

+ 18 - 0
Engine/source/console/consoleFunctions.cpp

@@ -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