diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-04 18:23:50 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-09 19:31:22 +0200 |
commit | 15b632bf169f6272ca90faba8d8036e3e822542f (patch) | |
tree | 1c6168fe4d60a2819f9d438a4940a98526017104 | |
parent | 540ca5111f7dc91a9808e41ccb4446d8dc0a1bec (diff) | |
download | bitcoin-15b632bf169f6272ca90faba8d8036e3e822542f.tar.xz |
Use ArgsManager::GetPathArg() for "-datadir" option
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/util/system.cpp | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp index 330aab5184..6aef1f8149 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1150,7 +1150,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); // Warn about relative -datadir path. - if (args.IsArgSet("-datadir") && !fs::PathFromString(args.GetArg("-datadir", "")).is_absolute()) { + if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) { LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */ "current working directory '%s'. This is fragile, because if bitcoin is started in the future " "from a different location, it will be unable to locate the current data files. There could " diff --git a/src/util/system.cpp b/src/util/system.cpp index 82770dc665..7bf1e8b8e5 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -440,9 +440,9 @@ const fs::path& ArgsManager::GetDataDir(bool net_specific) const // this function if (!path.empty()) return path; - std::string datadir = GetArg("-datadir", ""); + const fs::path datadir{GetPathArg("-datadir")}; if (!datadir.empty()) { - path = fs::absolute(StripRedundantLastElementsOfPath(fs::PathFromString(datadir))); + path = fs::absolute(datadir); if (!fs::is_directory(path)) { path = ""; return path; @@ -823,8 +823,8 @@ fs::path GetDefaultDataDir() bool CheckDataDirOption() { - std::string datadir = gArgs.GetArg("-datadir", ""); - return datadir.empty() || fs::is_directory(fs::absolute(fs::PathFromString(datadir))); + const fs::path datadir{gArgs.GetPathArg("-datadir")}; + return datadir.empty() || fs::is_directory(fs::absolute(datadir)); } fs::path GetConfigFile(const std::string& confPath) |