| 11969 | |
| 11970 | |
| 11971 | static int io_type (lua_State *L) { |
| 11972 | void *ud; |
| 11973 | luaL_checkany(L, 1); |
| 11974 | ud = lua_touserdata(L, 1); |
| 11975 | lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); |
| 11976 | if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) |
| 11977 | lua_pushnil(L); /* not a file */ |
| 11978 | else if (*((FILE **)ud) == NULL) |
| 11979 | lua_pushliteral(L, "closed file"); |
| 11980 | else |
| 11981 | lua_pushliteral(L, "file"); |
| 11982 | return 1; |
| 11983 | } |
| 11984 | |
| 11985 | |
| 11986 | static FILE *tofile (lua_State *L) { |
nothing calls this directly
no test coverage detected