File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -741,8 +741,9 @@ const fs::path &GetDataDir(bool fNetSpecific)
741
741
// this function
742
742
if (!path.empty ()) return path;
743
743
744
- if (gArgs .IsArgSet (" -datadir" )) {
745
- path = fs::system_complete (gArgs .GetArg (" -datadir" , " " ));
744
+ std::string datadir = gArgs .GetArg (" -datadir" , " " );
745
+ if (!datadir.empty ()) {
746
+ path = fs::system_complete (datadir);
746
747
if (!fs::is_directory (path)) {
747
748
path = " " ;
748
749
return path;
@@ -761,6 +762,12 @@ const fs::path &GetDataDir(bool fNetSpecific)
761
762
return path;
762
763
}
763
764
765
+ bool CheckDataDirOption ()
766
+ {
767
+ std::string datadir = gArgs .GetArg (" -datadir" , " " );
768
+ return datadir.empty () || fs::is_directory (fs::system_complete (datadir));
769
+ }
770
+
764
771
void ClearDatadirCache ()
765
772
{
766
773
LOCK (csPathCached);
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ fs::path GetDefaultDataDir();
83
83
// The blocks directory is always net specific.
84
84
const fs::path &GetBlocksDir ();
85
85
const fs::path &GetDataDir (bool fNetSpecific = true );
86
+ // Return true if -datadir option points to a valid directory or is not specified.
87
+ bool CheckDataDirOption ();
86
88
/* * Tests only */
87
89
void ClearDatadirCache ();
88
90
fs::path GetConfigFile (const std::string& confPath);
You can’t perform that action at this time.
0 commit comments