From 7b23d79dc2a5761298d6f997390886d174c581b9 Mon Sep 17 00:00:00 2001 From: hagen Date: Sun, 24 Jan 2016 11:13:38 +0000 Subject: [PATCH] * util.cpp : update Get*ConfigFile() : autodetect configs --- util.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/util.cpp b/util.cpp index e559d7f9..5f36f409 100644 --- a/util.cpp +++ b/util.cpp @@ -124,19 +124,33 @@ namespace filesystem boost::filesystem::path GetConfigFile() { std::string config; i2p::config::GetOption("conf", config); - boost::filesystem::path pathConfigFile(config); - if (!pathConfigFile.is_complete()) - pathConfigFile = GetDataDir() / pathConfigFile; - return pathConfigFile; + if (config != "") { + /* config file set with cmdline */ + boost::filesystem::path path(config); + return path; + } + /* else - try autodetect */ + boost::filesystem::path path("i2p.conf"); + path = GetDataDir() / path; + if (!boost::filesystem::exists(path)) + path = ""; /* reset */ + return path; } boost::filesystem::path GetTunnelsConfigFile() { std::string tunconf; i2p::config::GetOption("tunconf", tunconf); - boost::filesystem::path pathTunnelsConfigFile(tunconf); - if (!pathTunnelsConfigFile.is_complete()) - pathTunnelsConfigFile = GetDataDir() / pathTunnelsConfigFile; - return pathTunnelsConfigFile; + if (tunconf != "") { + /* config file set with cmdline */ + boost::filesystem::path path(tunconf); + return path; + } + /* else - try autodetect */ + boost::filesystem::path path("tunnels.cfg"); + path = GetDataDir() / path; + if (!boost::filesystem::exists(path)) + path = ""; /* reset */ + return path; } boost::filesystem::path GetDefaultDataDir()