MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / g_iofile

Function g_iofile

deps/lua/src/liolib.c:200–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199
200static int g_iofile (lua_State *L, int f, const char *mode) {
201 if (!lua_isnoneornil(L, 1)) {
202 const char *filename = lua_tostring(L, 1);
203 if (filename) {
204 FILE **pf = newfile(L);
205 *pf = fopen(filename, mode);
206 if (*pf == NULL)
207 fileerror(L, 1, filename);
208 }
209 else {
210 tofile(L); /* check that it's a valid file handle */
211 lua_pushvalue(L, 1);
212 }
213 lua_rawseti(L, LUA_ENVIRONINDEX, f);
214 }
215 /* return current value */
216 lua_rawgeti(L, LUA_ENVIRONINDEX, f);
217 return 1;
218}
219
220
221static int io_input (lua_State *L) {

Callers 2

io_inputFunction · 0.85
io_outputFunction · 0.85

Calls 6

newfileFunction · 0.85
fileerrorFunction · 0.85
tofileFunction · 0.85
lua_pushvalueFunction · 0.85
lua_rawsetiFunction · 0.85
lua_rawgetiFunction · 0.85

Tested by

no test coverage detected