diff --git a/src/dash-cli.cpp b/src/dash-cli.cpp index b4a5e3b7e3..9966f9c892 100644 --- a/src/dash-cli.cpp +++ b/src/dash-cli.cpp @@ -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 { diff --git a/src/dashd.cpp b/src/dashd.cpp index cfb21cbbb8..08204dfd3e 100644 --- a/src/dashd.cpp +++ b/src/dashd.cpp @@ -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; diff --git a/src/init.cpp b/src/init.cpp index 2926e6e009..2231bc19ed 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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); diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index e9d518dad5..f5fade9a12 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -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())); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 371c9ce455..1081488a46 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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)) diff --git a/src/util.cpp b/src/util.cpp index 0520395bd3..bac52950f1 100644 --- a/src/util.cpp +++ b/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& mapSettingsRet, +void ReadConfigFile(const std::string& confPath, + map& mapSettingsRet, map >& 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 diff --git a/src/util.h b/src/util.h index a61e2797b5..f375c65c53 100644 --- a/src/util.h +++ b/src/util.h @@ -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& mapSettingsRet, std::map >& mapMultiSettingsRet); +void ReadConfigFile(const std::string& confPath, std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true); #endif