Skip to content

Commit 15b632b

Browse files
committed
Use ArgsManager::GetPathArg() for "-datadir" option
1 parent 540ca51 commit 15b632b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11501150
LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
11511151

11521152
// Warn about relative -datadir path.
1153-
if (args.IsArgSet("-datadir") && !fs::PathFromString(args.GetArg("-datadir", "")).is_absolute()) {
1153+
if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) {
11541154
LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */
11551155
"current working directory '%s'. This is fragile, because if bitcoin is started in the future "
11561156
"from a different location, it will be unable to locate the current data files. There could "

src/util/system.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ const fs::path& ArgsManager::GetDataDir(bool net_specific) const
440440
// this function
441441
if (!path.empty()) return path;
442442

443-
std::string datadir = GetArg("-datadir", "");
443+
const fs::path datadir{GetPathArg("-datadir")};
444444
if (!datadir.empty()) {
445-
path = fs::absolute(StripRedundantLastElementsOfPath(fs::PathFromString(datadir)));
445+
path = fs::absolute(datadir);
446446
if (!fs::is_directory(path)) {
447447
path = "";
448448
return path;
@@ -823,8 +823,8 @@ fs::path GetDefaultDataDir()
823823

824824
bool CheckDataDirOption()
825825
{
826-
std::string datadir = gArgs.GetArg("-datadir", "");
827-
return datadir.empty() || fs::is_directory(fs::absolute(fs::PathFromString(datadir)));
826+
const fs::path datadir{gArgs.GetPathArg("-datadir")};
827+
return datadir.empty() || fs::is_directory(fs::absolute(datadir));
828828
}
829829

830830
fs::path GetConfigFile(const std::string& confPath)

0 commit comments

Comments
 (0)