| 255 | |
| 256 | |
| 257 | static int io_open (lua_State *L) { |
| 258 | const char *filename = luaL_checkstring(L, 1); |
| 259 | const char *mode = luaL_optstring(L, 2, "r"); |
| 260 | LStream *p = newfile(L); |
| 261 | const char *md = mode; /* to traverse/check mode */ |
| 262 | luaL_argcheck(L, l_checkmode(md), 2, "invalid mode"); |
| 263 | p->f = fopen(filename, mode); |
| 264 | return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; |
| 265 | } |
| 266 | |
| 267 | |
| 268 | /* |
nothing calls this directly
no test coverage detected