MCPcopy Create free account
hub / github.com/defold/defold / luaopen_io

Function luaopen_io

engine/lua/src/lua/liolib.c:538–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536
537
538LUALIB_API int luaopen_io (lua_State *L) {
539 createmeta(L);
540 /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
541 newfenv(L, io_fclose);
542 lua_replace(L, LUA_ENVIRONINDEX);
543 /* open library */
544 luaL_register(L, LUA_IOLIBNAME, iolib);
545 /* create (and set) default files */
546 newfenv(L, io_noclose); /* close function for default files */
547 createstdfile(L, stdin, IO_INPUT, "stdin");
548 createstdfile(L, stdout, IO_OUTPUT, "stdout");
549 createstdfile(L, stderr, 0, "stderr");
550 lua_pop(L, 1); /* pop environment for default files */
551 lua_getfield(L, -1, "popen");
552 newfenv(L, io_pclose); /* create environment for 'popen' */
553 lua_setfenv(L, -2); /* set fenv for 'popen' */
554 lua_pop(L, 1); /* pop 'popen' */
555 return 1;
556}
557

Callers

nothing calls this directly

Calls 6

createmetaFunction · 0.85
newfenvFunction · 0.85
lua_replaceFunction · 0.85
createstdfileFunction · 0.85
lua_getfieldFunction · 0.85
lua_setfenvFunction · 0.85

Tested by

no test coverage detected