MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / g_iofile

Function g_iofile

lua/liolib.c:208–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206
207
208static int g_iofile (lua_State *L, int f, const char *mode) {
209 if (!lua_isnoneornil(L, 1)) {
210 const char *filename = lua_tostring(L, 1);
211 if (filename) {
212 FILE **pf = newfile(L);
213 *pf = fopen(filename, mode);
214 if (*pf == NULL)
215 fileerror(L, 1, filename);
216 }
217 else {
218 tofile(L); /* check that it's a valid file handle */
219 lua_pushvalue(L, 1);
220 }
221 lua_rawseti(L, LUA_ENVIRONINDEX, f);
222 }
223 /* return current value */
224 lua_rawgeti(L, LUA_ENVIRONINDEX, f);
225 return 1;
226}
227
228
229static 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