Skip to content

Commit c6da7bc

Browse files
committed
Expose config dir in osm2pgsql.config_dir Lua var in flex output
The directory where the Lua config file was read from is now available in the osm2pgsql.config_dir variable. This is useful, for instance, when we want to include other files into our config file.
1 parent d4bccaa commit c6da7bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/output-flex.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ extern "C"
3636
#include <rapidjson/stringbuffer.h>
3737
#include <rapidjson/writer.h>
3838

39+
#include <boost/filesystem.hpp>
40+
3941
#include <cassert>
4042
#include <cstdlib>
4143
#include <cstring>
@@ -1630,6 +1632,10 @@ void output_flex_t::init_lua(std::string const &filename)
16301632
m_options.append ? "append" : "create");
16311633
luaX_add_table_int(lua_state(), "stage", 1);
16321634

1635+
std::string const dir_path =
1636+
boost::filesystem::path{filename}.parent_path().string();
1637+
luaX_add_table_str(lua_state(), "config_dir", dir_path.c_str());
1638+
16331639
luaX_add_table_func(lua_state(), "define_table",
16341640
lua_trampoline_app_define_table);
16351641

0 commit comments

Comments
 (0)