Browse Source

ios support

jet082 6 years ago
parent
commit
e92667c49c
1 changed files with 11 additions and 3 deletions
  1. 11 3
      sqstdlib/sqstdsystem.cpp

+ 11 - 3
sqstdlib/sqstdsystem.cpp

@@ -19,6 +19,10 @@
 #define scremove remove
 #define screname rename
 #endif
+#ifdef IOS
+	#include <spawn.h>
+	extern char **environ;
+#endif
 
 static SQInteger _system_getenv(HSQUIRRELVM v)
 {
@@ -30,18 +34,22 @@ static SQInteger _system_getenv(HSQUIRRELVM v)
     return 0;
 }
 
-
 static SQInteger _system_system(HSQUIRRELVM v)
 {
     const SQChar *s;
     if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
-        sq_pushinteger(v,scsystem(s));
+	#ifdef IOS
+		pid_t pid;
+		posix_spawn(&pid, s, NULL, NULL, NULL, environ);
+		sq_pushinteger(v, 0);
+	#else
+	        sq_pushinteger(v,scsystem(s));
+	#endif
         return 1;
     }
     return sq_throwerror(v,_SC("wrong param"));
 }
 
-
 static SQInteger _system_clock(HSQUIRRELVM v)
 {
     sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC);