| 55 | |
| 56 | |
| 57 | static int io_type (lua_State *L) { |
| 58 | void *ud; |
| 59 | luaL_checkany(L, 1); |
| 60 | ud = lua_touserdata(L, 1); |
| 61 | lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); |
| 62 | if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) |
| 63 | lua_pushnil(L); /* not a file */ |
| 64 | else if (*((FILE **)ud) == NULL) |
| 65 | lua_pushliteral(L, "closed file"); |
| 66 | else |
| 67 | lua_pushliteral(L, "file"); |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | static FILE *tofile (lua_State *L) { |
nothing calls this directly
no test coverage detected