mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 00:34:20 +00:00
* move ReadConfigFile() : i2p::filesystem -> i2p::config * don't export i2p::config::mapArgs outside namespace
This commit is contained in:
parent
6740ec464c
commit
7565843fbe
@ -65,7 +65,7 @@ namespace i2p
|
|||||||
|
|
||||||
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
|
LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
|
||||||
LogPrint(eLogDebug, "FS: data directory: ", i2p::util::filesystem::GetDataDir().string());
|
LogPrint(eLogDebug, "FS: data directory: ", i2p::util::filesystem::GetDataDir().string());
|
||||||
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs);
|
i2p::util::config::ReadConfigFile(i2p::util::filesystem::GetConfigFile());
|
||||||
|
|
||||||
isDaemon = i2p::util::config::GetArg("-daemon", 0);
|
isDaemon = i2p::util::config::GetArg("-daemon", 0);
|
||||||
isLogging = i2p::util::config::GetArg("-log", 1);
|
isLogging = i2p::util::config::GetArg("-log", 1);
|
||||||
|
40
util.cpp
40
util.cpp
@ -124,6 +124,26 @@ namespace config
|
|||||||
return atoi(mapArgs[strArg].c_str());
|
return atoi(mapArgs[strArg].c_str());
|
||||||
return nDefault;
|
return nDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReadConfigFile(boost::filesystem::path path)
|
||||||
|
{
|
||||||
|
boost::filesystem::ifstream streamConfig(path);
|
||||||
|
if (!streamConfig.good())
|
||||||
|
return; // No i2pd.conf file is OK
|
||||||
|
|
||||||
|
std::set<std::string> setOptions;
|
||||||
|
setOptions.insert("*");
|
||||||
|
|
||||||
|
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
|
||||||
|
{
|
||||||
|
// Don't overwrite existing settings so command line settings override i2pd.conf
|
||||||
|
std::string strKey = std::string("-") + it->string_key;
|
||||||
|
if (mapArgs.count(strKey) == 0)
|
||||||
|
{
|
||||||
|
mapArgs[strKey] = it->value[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace filesystem
|
namespace filesystem
|
||||||
@ -193,26 +213,6 @@ namespace filesystem
|
|||||||
return pathTunnelsConfigFile;
|
return pathTunnelsConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet)
|
|
||||||
{
|
|
||||||
boost::filesystem::ifstream streamConfig(GetConfigFile());
|
|
||||||
if (!streamConfig.good())
|
|
||||||
return; // No i2pd.conf file is OK
|
|
||||||
|
|
||||||
std::set<std::string> setOptions;
|
|
||||||
setOptions.insert("*");
|
|
||||||
|
|
||||||
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
|
|
||||||
{
|
|
||||||
// Don't overwrite existing settings so command line settings override i2pd.conf
|
|
||||||
std::string strKey = std::string("-") + it->string_key;
|
|
||||||
if (mapSettingsRet.count(strKey) == 0)
|
|
||||||
{
|
|
||||||
mapSettingsRet[strKey] = it->value[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::filesystem::path GetDefaultDataDir()
|
boost::filesystem::path GetDefaultDataDir()
|
||||||
{
|
{
|
||||||
// Windows < Vista: C:\Documents and Settings\Username\.i2pd
|
// Windows < Vista: C:\Documents and Settings\Username\.i2pd
|
||||||
|
3
util.h
3
util.h
@ -16,10 +16,10 @@ namespace util
|
|||||||
{
|
{
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
extern std::map<std::string, std::string> mapArgs;
|
|
||||||
void OptionParser(int argc, const char* const argv[]);
|
void OptionParser(int argc, const char* const argv[]);
|
||||||
int GetArg(const std::string& strArg, int nDefault);
|
int GetArg(const std::string& strArg, int nDefault);
|
||||||
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
std::string GetArg(const std::string& strArg, const std::string& strDefault);
|
||||||
|
void ReadConfigFile(boost::filesystem::path path);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace filesystem
|
namespace filesystem
|
||||||
@ -32,7 +32,6 @@ namespace util
|
|||||||
boost::filesystem::path GetDefaultDataDir();
|
boost::filesystem::path GetDefaultDataDir();
|
||||||
boost::filesystem::path GetConfigFile();
|
boost::filesystem::path GetConfigFile();
|
||||||
boost::filesystem::path GetTunnelsConfigFile();
|
boost::filesystem::path GetTunnelsConfigFile();
|
||||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet);
|
|
||||||
boost::filesystem::path GetCertificatesDir();
|
boost::filesystem::path GetCertificatesDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user