mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-23 14:10:15 +01:00
args: Properly support -noconf
-noconf would previously lead to an ifstream "successfully" being opened to the ".bitcoin"-directory (not a file). (Guards against the general case of directories as configs are added in grandchild commit to this one).
Other users of AbsPathForConfigVal() in combination with negated args have been updated earlier in this PR ("args: Support -nopid" and "args: Support -norpccookiefile...").
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -122,10 +123,11 @@ bool StartLogging(const ArgsManager& args)
|
||||
|
||||
// Only log conf file usage message if conf file actually exists.
|
||||
fs::path config_file_path = args.GetConfigFilePath();
|
||||
if (fs::exists(config_file_path)) {
|
||||
if (args.IsArgNegated("-conf")) {
|
||||
LogInfo("Config file: <disabled>");
|
||||
} else if (fs::exists(config_file_path)) {
|
||||
LogPrintf("Config file: %s\n", fs::PathToString(config_file_path));
|
||||
} else if (args.IsArgSet("-conf")) {
|
||||
// Warn if no conf file exists at path provided by user
|
||||
InitWarning(strprintf(_("The specified config file %s does not exist"), fs::PathToString(config_file_path)));
|
||||
} else {
|
||||
// Not categorizing as "Warning" because it's the default behavior
|
||||
|
||||
Reference in New Issue
Block a user