diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -103,7 +103,7 @@ * the datadir if they are not absolute. * * @param path The path to be conditionally prefixed with datadir. - * @param net_specific Forwarded to GetDataDir(). + * @param net_specific Use network specific datadir variant * @return The normalized path. */ fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific = true); @@ -240,6 +240,24 @@ */ const fs::path &GetBlocksDirPath() const; + /** + * Get data directory path + * + * @return Absolute path on success, otherwise an empty path when a + * non-directory path would be returned + * @post Returned directory path is created unless it is empty + */ + const fs::path &GetDataDirBase() const { return GetDataDirPath(false); } + + /** + * Get data directory path with appended network identifier + * + * @return Absolute path on success, otherwise an empty path when a + * non-directory path would be returned + * @post Returned directory path is created unless it is empty + */ + const fs::path &GetDataDirNet() const { return GetDataDirPath(true); } + /** * Get data directory path * diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -419,7 +419,7 @@ return path; } } else { - path = GetDataDirPath(false); + path = GetDataDirBase(); } path /= fs::PathFromString(BaseParams().DataDir()); @@ -511,7 +511,7 @@ std::string settings = GetArg("-settings", BITCOIN_SETTINGS_FILENAME); *filepath = fs::absolute( fs::PathFromString(temp ? settings + ".tmp" : settings), - GetDataDirPath(/* net_specific= */ true)); + GetDataDirNet()); } return true; } @@ -833,7 +833,7 @@ } const fs::path &GetDataDir(bool fNetSpecific) { - return gArgs.GetDataDirPath(fNetSpecific); + return fNetSpecific ? gArgs.GetDataDirNet() : gArgs.GetDataDirBase(); } bool CheckDataDirOption() { @@ -1386,7 +1386,8 @@ if (path.is_absolute()) { return path; } - return fs::absolute(path, GetDataDir(net_specific)); + return fs::absolute(path, net_specific ? gArgs.GetDataDirNet() + : gArgs.GetDataDirBase()); } void ScheduleBatchPriority() {