mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
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:
parent
23ac000008
commit
14483e46f9
@ -103,7 +103,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
try {
|
||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
@ -224,7 +224,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
|
||||
if (!GetAuthCookie(&strRPCUserColonPass)) {
|
||||
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)"),
|
||||
GetConfigFile().string().c_str()));
|
||||
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
|
||||
|
||||
}
|
||||
} else {
|
||||
|
@ -107,7 +107,7 @@ bool AppInit(int argc, char* argv[])
|
||||
}
|
||||
try
|
||||
{
|
||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||
return false;
|
||||
|
@ -1206,7 +1206,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
|
||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
||||
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 %u threads for script verification\n", nScriptCheckThreads);
|
||||
|
@ -635,7 +635,7 @@ int main(int argc, char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
try {
|
||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
|
||||
} catch (const std::exception& e) {
|
||||
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
|
||||
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
|
||||
|
@ -440,7 +440,7 @@ void openDebugLogfile()
|
||||
|
||||
void openConfigfile()
|
||||
{
|
||||
boost::filesystem::path pathConfig = GetConfigFile();
|
||||
boost::filesystem::path pathConfig = GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME));
|
||||
|
||||
/* Open dash.conf with the associated application */
|
||||
if (boost::filesystem::exists(pathConfig))
|
||||
|
14
src/util.cpp
14
src/util.cpp
@ -607,9 +607,9 @@ void ClearDatadirCache()
|
||||
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())
|
||||
pathConfigFile = GetDataDir(false) / pathConfigFile;
|
||||
|
||||
@ -619,17 +619,19 @@ boost::filesystem::path GetConfigFile()
|
||||
boost::filesystem::path GetMasternodeConfigFile()
|
||||
{
|
||||
boost::filesystem::path pathConfigFile(GetArg("-mnconf", "masternode.conf"));
|
||||
if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir() / pathConfigFile;
|
||||
if (!pathConfigFile.is_complete())
|
||||
pathConfigFile = GetDataDir() / pathConfigFile;
|
||||
return pathConfigFile;
|
||||
}
|
||||
|
||||
void ReadConfigFile(map<string, string>& mapSettingsRet,
|
||||
void ReadConfigFile(const std::string& confPath,
|
||||
map<string, string>& mapSettingsRet,
|
||||
map<string, vector<string> >& mapMultiSettingsRet)
|
||||
{
|
||||
boost::filesystem::ifstream streamConfig(GetConfigFile());
|
||||
boost::filesystem::ifstream streamConfig(GetConfigFile(confPath));
|
||||
if (!streamConfig.good()){
|
||||
// Create empty dash.conf if it does not excist
|
||||
FILE* configFile = fopen(GetConfigFile().string().c_str(), "a");
|
||||
FILE* configFile = fopen(GetConfigFile(confPath).string().c_str(), "a");
|
||||
if (configFile != NULL)
|
||||
fclose(configFile);
|
||||
return; // Nothing to read, so just return
|
||||
|
@ -124,13 +124,13 @@ boost::filesystem::path GetDefaultDataDir();
|
||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
|
||||
const boost::filesystem::path &GetBackupsDir();
|
||||
void ClearDatadirCache();
|
||||
boost::filesystem::path GetConfigFile();
|
||||
boost::filesystem::path GetConfigFile(const std::string& confPath);
|
||||
boost::filesystem::path GetMasternodeConfigFile();
|
||||
#ifndef WIN32
|
||||
boost::filesystem::path GetPidFile();
|
||||
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
|
||||
#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
|
||||
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user