| 2164 | } |
| 2165 | |
| 2166 | LUALIB_API bool luaL_is_bytecode_file(lua_State *L, const char *filename) |
| 2167 | { |
| 2168 | LoadF lf; |
| 2169 | int c; |
| 2170 | bool result = false; |
| 2171 | if (filename == nullptr) { |
| 2172 | lua_pushliteral(L, "=stdin"); |
| 2173 | lf.f = stdin; |
| 2174 | } |
| 2175 | else { |
| 2176 | lf.f = fopen(filename, "r"); |
| 2177 | if (lf.f == nullptr) return false; |
| 2178 | } |
| 2179 | if (skipcomment(&lf, &c)) /* read initial portion */ |
| 2180 | lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ |
| 2181 | if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ |
| 2182 | result = true; |
| 2183 | } |
| 2184 | if (filename) |
| 2185 | fclose(lf.f); |
| 2186 | return result; |
| 2187 | } |
| 2188 | |
| 2189 | LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, |
| 2190 | const char *mode) { |
no test coverage detected