Skip to content

Commit 0f53df4

Browse files
committed
Add ArgsManager.GetDataDirBase() and ArgsManager.GetDataDirNet() as an intended replacement for ArgsManager.GetDataDirPath(net_identifier)
1 parent 716de29 commit 0f53df4

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/util/system.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ const fs::path& ArgsManager::GetBlocksDirPath() const
404404
return path;
405405
}
406406
} else {
407-
path = GetDataDirPath(false);
407+
path = GetDataDirBase();
408408
}
409409

410410
path /= BaseParams().DataDir();
@@ -513,7 +513,7 @@ bool ArgsManager::GetSettingsPath(fs::path* filepath, bool temp) const
513513
}
514514
if (filepath) {
515515
std::string settings = GetArg("-settings", BITCOIN_SETTINGS_FILENAME);
516-
*filepath = fsbridge::AbsPathJoin(GetDataDirPath(/* net_specific= */ true), temp ? settings + ".tmp" : settings);
516+
*filepath = fsbridge::AbsPathJoin(GetDataDirNet(), temp ? settings + ".tmp" : settings);
517517
}
518518
return true;
519519
}
@@ -804,7 +804,7 @@ fs::path GetDefaultDataDir()
804804

805805
const fs::path &GetDataDir(bool fNetSpecific)
806806
{
807-
return gArgs.GetDataDirPath(fNetSpecific);
807+
return fNetSpecific ? gArgs.GetDataDirNet() : gArgs.GetDataDirBase();
808808
}
809809

810810
bool CheckDataDirOption()
@@ -1361,7 +1361,7 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific)
13611361
if (path.is_absolute()) {
13621362
return path;
13631363
}
1364-
return fsbridge::AbsPathJoin(GetDataDir(net_specific), path);
1364+
return fsbridge::AbsPathJoin(net_specific ? gArgs.GetDataDirNet() : gArgs.GetDataDirBase(), path);
13651365
}
13661366

13671367
void ScheduleBatchPriority()

src/util/system.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ UniValue RunCommandParseJSON(const std::string& str_command, const std::string&
119119
* the datadir if they are not absolute.
120120
*
121121
* @param path The path to be conditionally prefixed with datadir.
122-
* @param net_specific Forwarded to GetDataDir().
122+
* @param net_specific Use network specific datadir variant
123123
* @return The normalized path.
124124
*/
125125
fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific = true);
@@ -268,6 +268,22 @@ class ArgsManager
268268
*/
269269
const fs::path& GetBlocksDirPath() const;
270270

271+
/**
272+
* Get data directory path
273+
*
274+
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
275+
* @post Returned directory path is created unless it is empty
276+
*/
277+
const fs::path& GetDataDirBase() const { return GetDataDirPath(false); }
278+
279+
/**
280+
* Get data directory path with appended network identifier
281+
*
282+
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
283+
* @post Returned directory path is created unless it is empty
284+
*/
285+
const fs::path& GetDataDirNet() const { return GetDataDirPath(true); }
286+
271287
/**
272288
* Get data directory path
273289
*

0 commit comments

Comments
 (0)