Merge #8856: Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs
3450c18
Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs (Jorge Timón)
This commit is contained in:
commit
a7e5cbb209
6 changed files with 12 additions and 11 deletions
|
@ -92,7 +92,7 @@ static bool AppInitRPC(int argc, char* argv[])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
|
@ -209,7 +209,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
|
||||||
if (!GetAuthCookie(&strRPCUserColonPass)) {
|
if (!GetAuthCookie(&strRPCUserColonPass)) {
|
||||||
throw runtime_error(strprintf(
|
throw runtime_error(strprintf(
|
||||||
_("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
|
_("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
|
||||||
GetConfigFile().string().c_str()));
|
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool AppInit(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1064,7 +1064,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
|
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
|
||||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
||||||
LogPrintf("Using data directory %s\n", strDataDir);
|
LogPrintf("Using data directory %s\n", strDataDir);
|
||||||
LogPrintf("Using config file %s\n", GetConfigFile().string());
|
LogPrintf("Using config file %s\n", GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string());
|
||||||
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
|
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
|
||||||
|
|
||||||
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
|
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
|
||||||
|
|
|
@ -590,7 +590,7 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
|
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
|
||||||
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
|
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
|
||||||
|
|
|
@ -518,19 +518,20 @@ void ClearDatadirCache()
|
||||||
pathCachedNetSpecific = boost::filesystem::path();
|
pathCachedNetSpecific = boost::filesystem::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path GetConfigFile()
|
boost::filesystem::path GetConfigFile(const std::string& confPath)
|
||||||
{
|
{
|
||||||
boost::filesystem::path pathConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME));
|
boost::filesystem::path pathConfigFile(confPath);
|
||||||
if (!pathConfigFile.is_complete())
|
if (!pathConfigFile.is_complete())
|
||||||
pathConfigFile = GetDataDir(false) / pathConfigFile;
|
pathConfigFile = GetDataDir(false) / pathConfigFile;
|
||||||
|
|
||||||
return pathConfigFile;
|
return pathConfigFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadConfigFile(map<string, string>& mapSettingsRet,
|
void ReadConfigFile(const std::string& confPath,
|
||||||
|
map<string, string>& mapSettingsRet,
|
||||||
map<string, vector<string> >& mapMultiSettingsRet)
|
map<string, vector<string> >& mapMultiSettingsRet)
|
||||||
{
|
{
|
||||||
boost::filesystem::ifstream streamConfig(GetConfigFile());
|
boost::filesystem::ifstream streamConfig(GetConfigFile(confPath));
|
||||||
if (!streamConfig.good())
|
if (!streamConfig.good())
|
||||||
return; // No bitcoin.conf file is OK
|
return; // No bitcoin.conf file is OK
|
||||||
|
|
||||||
|
|
|
@ -102,12 +102,12 @@ bool TryCreateDirectory(const boost::filesystem::path& p);
|
||||||
boost::filesystem::path GetDefaultDataDir();
|
boost::filesystem::path GetDefaultDataDir();
|
||||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
||||||
void ClearDatadirCache();
|
void ClearDatadirCache();
|
||||||
boost::filesystem::path GetConfigFile();
|
boost::filesystem::path GetConfigFile(const std::string& confPath);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
boost::filesystem::path GetPidFile();
|
boost::filesystem::path GetPidFile();
|
||||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
||||||
#endif
|
#endif
|
||||||
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
void ReadConfigFile(const std::string& confPath, std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue