MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / luaAddScriptFolderToLoadPath

Function luaAddScriptFolderToLoadPath

include/util/lua_util.hpp:21–27  ·  view source on GitHub ↗

Add the folder contain the script to the lua load path, so script can easily require() other lua scripts inside that folder, or subfolders. See http://lua-users.org/wiki/PackagePath for details on the package.path syntax.

Source from the content-addressed store, hash-verified

19// scripts inside that folder, or subfolders.
20// See http://lua-users.org/wiki/PackagePath for details on the package.path syntax.
21inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name)
22{
23 std::filesystem::path profile_path = std::filesystem::canonical(file_name);
24 std::string folder = profile_path.parent_path().generic_string();
25 const std::string lua_code = "package.path = \"" + folder + "/?.lua;\" .. package.path";
26 luaL_dostring(lua_state, lua_code.c_str());
27}
28} // namespace osrm::util
29
30#endif // LUA_UTIL_HPP

Callers 1

InitContextMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected