MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / LuaInclude

Method LuaInclude

src/auto4_lua.cpp:592–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 4

check_stringFunction · 0.85
errorFunction · 0.85
LoadFileFunction · 0.85
GetFilenameMethod · 0.80

Tested by

no test coverage detected