| 590 | |
| 591 | |
| 592 | int LuaScript::LuaInclude(lua_State *L) |
| 593 | { |
| 594 | const LuaScript *s = GetScriptObject(L); |
| 595 | |
| 596 | const std::string filename(check_string(L, 1)); |
| 597 | agi::fs::path filepath; |
| 598 | |
| 599 | // Relative or absolute path |
| 600 | if (!boost::all(filename, !boost::is_any_of("/\\"))) |
| 601 | filepath = s->GetFilename().parent_path()/filename; |
| 602 | else { // Plain filename |
| 603 | for (auto const& dir : s->include_path) { |
| 604 | filepath = dir/filename; |
| 605 | if (agi::fs::FileExists(filepath)) |
| 606 | break; |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | if (!agi::fs::FileExists(filepath)) |
| 611 | return error(L, "Lua include not found: %s", filename.c_str()); |
| 612 | |
| 613 | if (!LoadFile(L, filepath)) |
| 614 | return error(L, "Error loading Lua include \"%s\":\n%s", filename.c_str(), check_string(L, 1).c_str()); |
| 615 | |
| 616 | int pretop = lua_gettop(L) - 1; // don't count the function value itself |
| 617 | lua_call(L, 0, LUA_MULTRET); |
| 618 | return lua_gettop(L) - pretop; |
| 619 | } |
| 620 | |
| 621 | void LuaThreadedCall(lua_State *L, int nargs, int nresults, std::string const& title, wxWindow *parent, bool can_open_config) |
| 622 | { |
nothing calls this directly
no test coverage detected