BOOST Filesystem to load config file.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 27 Jul 2009 08:15:19 +0000 (10:15 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Mon, 27 Jul 2009 08:15:19 +0000 (10:15 +0200)
src/config.cpp
src/config.h

index 7727464..eb956c7 100644 (file)
@@ -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;
 }
 
 
index 190ac34..d287917 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <boost/program_options.hpp>
 #include <boost/foreach.hpp>
+#include <boost/filesystem.hpp>
+
 #include <string>
 #include <iostream>
 #include <fstream>
@@ -24,6 +26,8 @@
 #include "ods.h"
 
 namespace po = boost::program_options;
+namespace fs = boost::filesystem;
+
 using namespace std;
 
 class Config{