From: Bjoern Sikora Date: Mon, 27 Jul 2009 08:15:19 +0000 (+0200) Subject: BOOST Filesystem to load config file. X-Git-Tag: v1.1~276 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=7ec77cf125ac21e7a6c0ef7aa99ab84c71c680d1;p=bpdyndnsd BOOST Filesystem to load config file. --- diff --git a/src/config.cpp b/src/config.cpp index 7727464..eb956c7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -107,6 +107,37 @@ int Config::parse_cmd_line(int argc, char *argv[]) int Config::load_config_from_files(string config_path) { + fs::path full_config_path = fs::system_complete(fs::path(config_path)); + + if( fs::exists(full_config_path) && fs::is_directory(full_config_path)) + { + fs::directory_iterator end_iter; + for(fs::directory_iterator dir_itr(full_config_path); dir_itr != end_iter; ++dir_itr) + { + if( fs::is_regular_file(dir_itr->status())) + { + string filename = dir_itr->path().filename(); + if(filename == "bpdyndnsd.conf") + { + cout << filename << endl; + } + } + } + + } + else + { + cout << "Path doesn't exist or is not a directory" << endl; + return 4; + } + + + + + + +/* + // first load the main config file bpdyndnsd.conf string main_conf_file = config_path.append("/bpdyndnsd.conf"); ifstream config_file (main_conf_file.c_str(),ifstream::in); @@ -143,10 +174,11 @@ int Config::load_config_from_files(string config_path) cout << "Can't open main config file for reading: " << main_conf_file << endl; return 4; } - +*/ // then load all service definition files in config path // TODO: code to load service definition files in config path + return -1; } diff --git a/src/config.h b/src/config.h index 190ac34..d287917 100644 --- a/src/config.h +++ b/src/config.h @@ -14,6 +14,8 @@ #include #include +#include + #include #include #include @@ -24,6 +26,8 @@ #include "ods.h" namespace po = boost::program_options; +namespace fs = boost::filesystem; + using namespace std; class Config{