Add CheckDataDirOption() function
This commit is contained in:
parent
c1f325126c
commit
740d41ce9f
2 changed files with 11 additions and 2 deletions
|
@ -741,8 +741,9 @@ const fs::path &GetDataDir(bool fNetSpecific)
|
||||||
// this function
|
// this function
|
||||||
if (!path.empty()) return path;
|
if (!path.empty()) return path;
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-datadir")) {
|
std::string datadir = gArgs.GetArg("-datadir", "");
|
||||||
path = fs::system_complete(gArgs.GetArg("-datadir", ""));
|
if (!datadir.empty()) {
|
||||||
|
path = fs::system_complete(datadir);
|
||||||
if (!fs::is_directory(path)) {
|
if (!fs::is_directory(path)) {
|
||||||
path = "";
|
path = "";
|
||||||
return path;
|
return path;
|
||||||
|
@ -761,6 +762,12 @@ const fs::path &GetDataDir(bool fNetSpecific)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckDataDirOption()
|
||||||
|
{
|
||||||
|
std::string datadir = gArgs.GetArg("-datadir", "");
|
||||||
|
return datadir.empty() || fs::is_directory(fs::system_complete(datadir));
|
||||||
|
}
|
||||||
|
|
||||||
void ClearDatadirCache()
|
void ClearDatadirCache()
|
||||||
{
|
{
|
||||||
LOCK(csPathCached);
|
LOCK(csPathCached);
|
||||||
|
|
|
@ -83,6 +83,8 @@ fs::path GetDefaultDataDir();
|
||||||
// The blocks directory is always net specific.
|
// The blocks directory is always net specific.
|
||||||
const fs::path &GetBlocksDir();
|
const fs::path &GetBlocksDir();
|
||||||
const fs::path &GetDataDir(bool fNetSpecific = true);
|
const fs::path &GetDataDir(bool fNetSpecific = true);
|
||||||
|
// Return true if -datadir option points to a valid directory or is not specified.
|
||||||
|
bool CheckDataDirOption();
|
||||||
/** Tests only */
|
/** Tests only */
|
||||||
void ClearDatadirCache();
|
void ClearDatadirCache();
|
||||||
fs::path GetConfigFile(const std::string& confPath);
|
fs::path GetConfigFile(const std::string& confPath);
|
||||||
|
|
Loading…
Add table
Reference in a new issue