Merge pull request #204 from jet082/master

ios support
This commit is contained in:
Alberto Demichelis
2020-03-11 17:00:37 +08:00
committed by GitHub

View File

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