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

Function luaopen_io

lib/lua/src/liolib.c:534–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

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