MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaopen_io

Function luaopen_io

Source/Misc/lua/src/lua.c:12448–12466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12446
12447
12448LUALIB_API int luaopen_io (lua_State *L) {
12449createmeta(L);
12450/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
12451newfenv(L, io_fclose);
12452lua_replace(L, LUA_ENVIRONINDEX);
12453/* open library */
12454luaL_register(L, LUA_IOLIBNAME, iolib);
12455/* create (and set) default files */
12456newfenv(L, io_noclose); /* close function for default files */
12457createstdfile(L, stdin, IO_INPUT, "stdin");
12458createstdfile(L, stdout, IO_OUTPUT, "stdout");
12459createstdfile(L, stderr, 0, "stderr");
12460lua_pop(L, 1); /* pop environment for default files */
12461lua_getfield(L, -1, "popen");
12462newfenv(L, io_pclose); /* create environment for 'popen' */
12463lua_setfenv(L, -2); /* set fenv for 'popen' */
12464lua_pop(L, 1); /* pop 'popen' */
12465return 1;
12466}
12467
12468/*
12469** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $

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