Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
osrm-backend/include/util/lua_util.hpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (25 sloc)
891 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef LUA_UTIL_HPP | |
| #define LUA_UTIL_HPP | |
| extern "C" | |
| { | |
| #include <lauxlib.h> | |
| #include <lua.h> | |
| #include <lualib.h> | |
| } | |
| #include <boost/filesystem/convenience.hpp> | |
| #include <iostream> | |
| #include <string> | |
| namespace osrm::util | |
| { | |
| // 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. | |
| inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) | |
| { | |
| boost::filesystem::path profile_path = boost::filesystem::canonical(file_name); | |
| std::string folder = profile_path.parent_path().generic_string(); | |
| const std::string lua_code = "package.path = \"" + folder + "/?.lua;\" .. package.path"; | |
| luaL_dostring(lua_state, lua_code.c_str()); | |
| } | |
| } // namespace osrm::util | |
| #endif // LUA_UTIL_HPP |