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

Function g_iofile

engine/lua/src/lua/liolib.c:204–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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