Skip to content

Commit

Permalink
Merge pull request #37 from EOSIO/expose_config_file_path
Browse files Browse the repository at this point in the history
Expose the config file path used
  • Loading branch information
heifner committed Nov 2, 2018
2 parents 6e440a7 + 20f5e96 commit f3a63c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
21 changes: 13 additions & 8 deletions application.cpp
Expand Up @@ -26,6 +26,7 @@ class application_impl {
bfs::path _data_dir{"data-dir"};
bfs::path _config_dir{"config-dir"};
bfs::path _logging_conf{"logging.json"};
bfs::path _config_file_name;

uint64_t _version;
};
Expand Down Expand Up @@ -159,20 +160,20 @@ bool application::initialize_impl(int argc, char** argv, vector<abstract_plugin*
my->_logging_conf = logconf;

workaround = options["config"].as<std::string>();
bfs::path config_file_name = workaround;
if( config_file_name.is_relative() )
config_file_name = my->_config_dir / config_file_name;
my->_config_file_name = workaround;
if( my->_config_file_name.is_relative() )
my->_config_file_name = my->_config_dir / my->_config_file_name;

if(!bfs::exists(config_file_name)) {
if(config_file_name.compare(my->_config_dir / "config.ini") != 0)
if(!bfs::exists(my->_config_file_name)) {
if(my->_config_file_name.compare(my->_config_dir / "config.ini") != 0)
{
cout << "Config file " << config_file_name << " missing." << std::endl;
cout << "Config file " << my->_config_file_name << " missing." << std::endl;
return false;
}
write_default_config(config_file_name);
write_default_config(my->_config_file_name);
}

bpo::store(bpo::parse_config_file<char>(config_file_name.make_preferred().string().c_str(),
bpo::store(bpo::parse_config_file<char>(my->_config_file_name.make_preferred().string().c_str(),
my->_cfg_options, false), options);

if(options.count("plugin") > 0)
Expand Down Expand Up @@ -317,4 +318,8 @@ bfs::path application::config_dir() const {
return my->_config_dir;
}

bfs::path application::full_config_file_path() const {
return bfs::canonical(my->_config_file_name);
}

} /// namespace appbase
6 changes: 6 additions & 0 deletions include/appbase/application.hpp
Expand Up @@ -58,6 +58,12 @@ namespace appbase {
* @return Logging configuration location from command line
*/
bfs::path get_logging_conf() const;
/** @brief Get full config.ini path
*
* @return Config directory & config file name, possibly from command line. Only
* valid after initialize() has been called.
*/
bfs::path full_config_file_path() const;
/**
* @brief Looks for the --plugin commandline / config option and calls initialize on those plugins
*
Expand Down

0 comments on commit f3a63c1

Please sign in to comment.