aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-04-09 23:50:56 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-04-11 22:30:23 +0200
commitee12c3d60c4bb7b25e06709e92344d2d8b2c581e (patch)
tree1928de3b16dfd343ce00c0f79b2fb2dd70a914ee /src/util.h
parentbcaa5f1c0410b7c09405cc1d8515b4d973d13d1f (diff)
downloadbitcoin-ee12c3d60c4bb7b25e06709e92344d2d8b2c581e.tar.xz
Use filesystem::path instead of manual string tinkering
Where possible, use boost::filesystem::path instead of std::string or char* for filenames. This avoids a lot of manual string tinkering, in favor of path::operator/. GetDataDir is also reworked significantly, it now only keeps two cached directory names (the network-specific data dir, and the root data dir), which are decided through a parameter instead of pre-initialized global variables. Finally, remove the "upgrade from 0.1.5" case where a debug.log in the current directory has to be removed.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/util.h b/src/util.h
index a04ab2c948..d205260d8e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -19,6 +19,8 @@ typedef int pid_t; /* define for windows compatiblity */
#include <string>
#include <boost/thread.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/path.hpp>
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_condition.hpp>
@@ -111,7 +113,6 @@ extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
extern bool fPrintToConsole;
extern bool fPrintToDebugger;
-extern char pszSetDataDir[MAX_PATH];
extern bool fRequestShutdown;
extern bool fShutdown;
extern bool fDaemon;
@@ -153,16 +154,15 @@ void ParseParameters(int argc, const char*const argv[]);
bool WildcardMatch(const char* psz, const char* mask);
bool WildcardMatch(const std::string& str, const std::string& mask);
int GetFilesize(FILE* file);
-void GetDataDir(char* pszDirRet);
-std::string GetConfigFile();
-std::string GetPidFile();
-void CreatePidFile(std::string pidFile, pid_t pid);
+boost::filesystem::path GetDefaultDataDir();
+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);
#ifdef WIN32
-std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);
+boost::filesystem::path MyGetSpecialFolderPath(int nFolder, bool fCreate);
#endif
-std::string GetDefaultDataDir();
-std::string GetDataDir();
void ShrinkDebugFile();
int GetRandInt(int nMax);
uint64 GetRand(uint64 nMax);