From ee12c3d60c4bb7b25e06709e92344d2d8b2c581e Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 9 Apr 2012 23:50:56 +0200 Subject: 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. --- src/util.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/util.h') 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 #include +#include +#include #include #include #include @@ -111,7 +113,6 @@ extern std::map > 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& mapSettingsRet, std::map >& 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); -- cgit v1.2.3