mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
refactor: Block unsafe fs::path std::string conversion calls
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding calls to methods which will be unsafe after the transaction to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Kiminuo <kiminuo@protonmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
@@ -81,7 +81,7 @@ void AddLoggingArgs(ArgsManager& argsman)
|
||||
void SetLoggingOptions(const ArgsManager& args)
|
||||
{
|
||||
LogInstance().m_print_to_file = !args.IsArgNegated("-debuglogfile");
|
||||
LogInstance().m_file_path = AbsPathForConfigVal(args.GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE));
|
||||
LogInstance().m_file_path = AbsPathForConfigVal(fs::PathFromString(args.GetArg("-debuglogfile", DEFAULT_DEBUGLOGFILE)));
|
||||
LogInstance().m_print_to_console = args.GetBoolArg("-printtoconsole", !args.GetBoolArg("-daemon", false));
|
||||
LogInstance().m_log_timestamps = args.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
|
||||
LogInstance().m_log_time_micros = args.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
||||
@@ -128,24 +128,24 @@ bool StartLogging(const ArgsManager& args)
|
||||
}
|
||||
if (!LogInstance().StartLogging()) {
|
||||
return InitError(strprintf(Untranslated("Could not open debug log file %s"),
|
||||
LogInstance().m_file_path.string()));
|
||||
fs::PathToString(LogInstance().m_file_path)));
|
||||
}
|
||||
|
||||
if (!LogInstance().m_log_timestamps)
|
||||
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
|
||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
||||
LogPrintf("Using data directory %s\n", gArgs.GetDataDirNet().string());
|
||||
LogPrintf("Default data directory %s\n", fs::PathToString(GetDefaultDataDir()));
|
||||
LogPrintf("Using data directory %s\n", fs::PathToString(gArgs.GetDataDirNet()));
|
||||
|
||||
// Only log conf file usage message if conf file actually exists.
|
||||
fs::path config_file_path = GetConfigFile(args.GetArg("-conf", BITCOIN_CONF_FILENAME));
|
||||
if (fs::exists(config_file_path)) {
|
||||
LogPrintf("Config file: %s\n", config_file_path.string());
|
||||
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"), config_file_path.string()));
|
||||
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
|
||||
LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string());
|
||||
LogPrintf("Config file: %s (not found, skipping)\n", fs::PathToString(config_file_path));
|
||||
}
|
||||
|
||||
// Log the config arguments to debug.log
|
||||
|
||||
Reference in New Issue
Block a user