| 247 | |
| 248 | |
| 249 | LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { |
| 250 | int en = errno; /* calls to Lua API may change this value */ |
| 251 | if (stat) { |
| 252 | lua_pushboolean(L, 1); |
| 253 | return 1; |
| 254 | } |
| 255 | else { |
| 256 | const char *msg; |
| 257 | luaL_pushfail(L); |
| 258 | msg = (en != 0) ? strerror(en) : "(no extra info)"; |
| 259 | if (fname) |
| 260 | lua_pushfstring(L, "%s: %s", fname, msg); |
| 261 | else |
| 262 | lua_pushstring(L, msg); |
| 263 | lua_pushinteger(L, en); |
| 264 | return 3; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | |
| 269 | #if !defined(l_inspectstat) /* { */ |
no test coverage detected