Переглянути джерело

Merge pull request #741 from Areloch/systemCommandFunction

Adds a systemCommand console utility function
Brian Roberts 3 роки тому
батько
коміт
dad0149dfe
1 змінених файлів з 18 додано та 0 видалено
  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;
    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