From 264fee4fb3b5ad1c4682a9f233ef781318f74cc8 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 28 Mar 2015 08:27:19 +0300 Subject: support ~ variable in config path --- server/src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/src/main.cpp') diff --git a/server/src/main.cpp b/server/src/main.cpp index 67e5fa6..08fe5b7 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -61,10 +61,15 @@ int main(int argc, char *argv[]) if(vm.count("config")) config_path = vm["config"].as(); - if(boost::filesystem::exists(config_path) && boost::filesystem::is_regular(config_path)) - bpt::read_info(config_path, config); //TODO: finish this - else - std::cerr<<"failed to load config: \"" + config_path + "\", file does not exists or is not regular file\n"; + { + std::string tmp_path = config_path, home = getenv("HOME"); + for(std::string::size_type p1 = tmp_path.find("~"); p1 != std::string::npos; p1 = tmp_path.find("~", p1)) + tmp_path.replace(p1, 1, home); + if(boost::filesystem::exists(tmp_path) && boost::filesystem::is_regular(tmp_path)) + bpt::read_info(tmp_path, config); //TODO: finish this + else + std::cerr<<"failed to load config: \"" + config_path + "\", file does not exists or is not regular file\n"; + } if(vm.count("help")) -- cgit v1.2.3