Browse Source

* util.cpp : update Get*ConfigFile() : autodetect configs

pull/358/head
hagen 9 years ago
parent
commit
7b23d79dc2
  1. 30
      util.cpp

30
util.cpp

@ -124,19 +124,33 @@ namespace filesystem
boost::filesystem::path GetConfigFile() boost::filesystem::path GetConfigFile()
{ {
std::string config; i2p::config::GetOption("conf", config); std::string config; i2p::config::GetOption("conf", config);
boost::filesystem::path pathConfigFile(config); if (config != "") {
if (!pathConfigFile.is_complete()) /* config file set with cmdline */
pathConfigFile = GetDataDir() / pathConfigFile; boost::filesystem::path path(config);
return pathConfigFile; 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() boost::filesystem::path GetTunnelsConfigFile()
{ {
std::string tunconf; i2p::config::GetOption("tunconf", tunconf); std::string tunconf; i2p::config::GetOption("tunconf", tunconf);
boost::filesystem::path pathTunnelsConfigFile(tunconf); if (tunconf != "") {
if (!pathTunnelsConfigFile.is_complete()) /* config file set with cmdline */
pathTunnelsConfigFile = GetDataDir() / pathTunnelsConfigFile; boost::filesystem::path path(tunconf);
return pathTunnelsConfigFile; 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() boost::filesystem::path GetDefaultDataDir()

Loading…
Cancel
Save