diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-03-28 08:27:19 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-03-28 08:27:19 +0300 |
commit | 264fee4fb3b5ad1c4682a9f233ef781318f74cc8 (patch) | |
tree | a5b5fd148b7aab03e57445729f2f5ad5a0c9d497 /server/src | |
parent | ff44c9cd55bff146c6c47277656a967045184c7b (diff) |
support ~ variable in config path
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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<std::string>(); - 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")) |