diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-22 14:35:22 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-22 17:38:47 +0200 |
commit | f4203de3021ca67f065d163b332e9814aee842d8 (patch) | |
tree | da3a6e5adc51ba5b1607b48ea22dc10b87ceef75 /src | |
parent | 457661f6400030f5979564462e8c625840cc5e58 (diff) |
Make GetDataDir return absolute paths
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 3 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 3 | ||||
-rw-r--r-- | src/util.cpp | 11 | ||||
-rw-r--r-- | src/util.h | 2 |
4 files changed, 12 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp index 14db9e7f5e..e7f1c7c015 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -150,11 +150,12 @@ bool AppInit2(int argc, char* argv[]) // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() #if !defined(QT_GUI) ParseParameters(argc, argv); - if (!ReadConfigFile(mapArgs, mapMultiArgs)) + if (!boost::filesystem::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified directory does not exist\n"); Shutdown(NULL); } + ReadConfigFile(mapArgs, mapMultiArgs); #endif if (mapArgs.count("-?") || mapArgs.count("--help")) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index c7830871b5..7c262e14cd 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -168,11 +168,12 @@ int main(int argc, char *argv[]) ParseParameters(argc, argv); // ... then bitcoin.conf: - if (!ReadConfigFile(mapArgs, mapMultiArgs)) + if (!boost::filesystem::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified directory does not exist\n"); return 1; } + ReadConfigFile(mapArgs, mapMultiArgs); // Application identification (must be set before OptionsModel is initialized, // as it is used to locate QSettings) diff --git a/src/util.cpp b/src/util.cpp index 9f2de3449d..7322b1e228 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -870,7 +870,11 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) LOCK(csPathCached); if (mapArgs.count("-datadir")) { - path = mapArgs["-datadir"]; + path = fs::system_complete(mapArgs["-datadir"]); + if (!fs::is_directory(path)) { + path = ""; + return path; + } } else { path = GetDefaultDataDir(); } @@ -892,7 +896,7 @@ boost::filesystem::path GetConfigFile() return pathConfigFile; } -bool ReadConfigFile(map<string, string>& mapSettingsRet, +void ReadConfigFile(map<string, string>& mapSettingsRet, map<string, vector<string> >& mapMultiSettingsRet) { namespace fs = boost::filesystem; @@ -900,7 +904,7 @@ bool ReadConfigFile(map<string, string>& mapSettingsRet, fs::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()) - return true; // No bitcoin.conf file is OK + return; // No bitcoin.conf file is OK set<string> setOptions; setOptions.insert("*"); @@ -917,7 +921,6 @@ bool ReadConfigFile(map<string, string>& mapSettingsRet, } mapMultiSettingsRet[strKey].push_back(it->value[0]); } - return true; } boost::filesystem::path GetPidFile() diff --git a/src/util.h b/src/util.h index fe8ca60b47..9035b773f1 100644 --- a/src/util.h +++ b/src/util.h @@ -162,7 +162,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific = true); boost::filesystem::path GetConfigFile(); boost::filesystem::path GetPidFile(); void CreatePidFile(const boost::filesystem::path &path, pid_t pid); -bool ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet); +void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet); bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart); void ShrinkDebugFile(); |