diff options
| author | Hennadii Stepanov <[email protected]> | 2019-07-24 03:21:25 +0300 |
|---|---|---|
| committer | Hennadii Stepanov <[email protected]> | 2019-07-24 18:43:07 +0300 |
| commit | 740d41ce9f7fdf209366e930bd0fdcc6b1bc6b79 (patch) | |
| tree | 81316e881a53828af3f4d99afa13c361ebe31f9c /src/util/system.cpp | |
| parent | Return absolute path early in AbsPathForConfigVal (diff) | |
| download | discoin-740d41ce9f7fdf209366e930bd0fdcc6b1bc6b79.tar.xz discoin-740d41ce9f7fdf209366e930bd0fdcc6b1bc6b79.zip | |
Add CheckDataDirOption() function
Diffstat (limited to 'src/util/system.cpp')
| -rw-r--r-- | src/util/system.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index d9e23199e..520ed3550 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -741,8 +741,9 @@ const fs::path &GetDataDir(bool fNetSpecific) // this function if (!path.empty()) return path; - if (gArgs.IsArgSet("-datadir")) { - path = fs::system_complete(gArgs.GetArg("-datadir", "")); + std::string datadir = gArgs.GetArg("-datadir", ""); + if (!datadir.empty()) { + path = fs::system_complete(datadir); if (!fs::is_directory(path)) { path = ""; return path; @@ -761,6 +762,12 @@ const fs::path &GetDataDir(bool fNetSpecific) return path; } +bool CheckDataDirOption() +{ + std::string datadir = gArgs.GetArg("-datadir", ""); + return datadir.empty() || fs::is_directory(fs::system_complete(datadir)); +} + void ClearDatadirCache() { LOCK(csPathCached); |