From e92667c49c026a53305c72ec7c9aa548dba42818 Mon Sep 17 00:00:00 2001 From: jet082 Date: Sat, 16 Nov 2019 08:21:16 -0800 Subject: [PATCH] ios support --- sqstdlib/sqstdsystem.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sqstdlib/sqstdsystem.cpp b/sqstdlib/sqstdsystem.cpp index b008a44..d326be1 100644 --- a/sqstdlib/sqstdsystem.cpp +++ b/sqstdlib/sqstdsystem.cpp @@ -19,6 +19,10 @@ #define scremove remove #define screname rename #endif +#ifdef IOS + #include + 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);