| 267 | |
| 268 | |
| 269 | static int io_open (lua_State *L) { |
| 270 | const char *filename = luaL_checkstring(L, 1); |
| 271 | const char *mode = luaL_optstring(L, 2, "r"); |
| 272 | LStream *p = newfile(L); |
| 273 | const char *md = mode; /* to traverse/check mode */ |
| 274 | luaL_argcheck(L, l_checkmode(md), 2, "invalid mode"); |
| 275 | p->f = fopen(filename, mode); |
| 276 | return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /* |
nothing calls this directly
no test coverage detected