Browse Source

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.
miguelfreitas
Pieter Wuille 13 years ago
parent
commit
ee12c3d60c
  1. 8
      src/bitcoinrpc.cpp
  2. 20
      src/db.cpp
  3. 36
      src/init.cpp
  4. 2
      src/main.cpp
  5. 136
      src/util.cpp
  6. 16
      src/util.h

8
src/bitcoinrpc.cpp

@ -2364,7 +2364,7 @@ void ThreadRPCServer2(void* parg)
"(you do not need to remember this password)\n" "(you do not need to remember this password)\n"
"If the file does not exist, create it with owner-readable-only file permissions.\n"), "If the file does not exist, create it with owner-readable-only file permissions.\n"),
strWhatAmI.c_str(), strWhatAmI.c_str(),
GetConfigFile().c_str(), GetConfigFile().string().c_str(),
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()), EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()),
_("Error"), wxOK | wxMODAL); _("Error"), wxOK | wxMODAL);
QueueShutdown(); QueueShutdown();
@ -2399,12 +2399,12 @@ void ThreadRPCServer2(void* parg)
filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert")); filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile; if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile;
if (filesystem::exists(pathCertFile)) context.use_certificate_chain_file(pathCertFile.string().c_str()); if (filesystem::exists(pathCertFile)) context.use_certificate_chain_file(pathCertFile.string());
else printf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str()); else printf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string().c_str());
filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem")); filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile; if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile;
if (filesystem::exists(pathPKFile)) context.use_private_key_file(pathPKFile.string().c_str(), ssl::context::pem); if (filesystem::exists(pathPKFile)) context.use_private_key_file(pathPKFile.string(), ssl::context::pem);
else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str()); else printf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string().c_str());
string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH"); string strCiphers = GetArg("-rpcsslciphers", "TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH");
@ -2544,7 +2544,7 @@ Object CallRPC(const string& strMethod, const Array& params)
throw runtime_error(strprintf( throw runtime_error(strprintf(
_("You must set rpcpassword=<password> in the configuration file:\n%s\n" _("You must set rpcpassword=<password> in the configuration file:\n%s\n"
"If the file does not exist, create it with owner-readable-only file permissions."), "If the file does not exist, create it with owner-readable-only file permissions."),
GetConfigFile().c_str())); GetConfigFile().string().c_str()));
// Connect to localhost // Connect to localhost
bool fUseSSL = GetBoolArg("-rpcssl"); bool fUseSSL = GetBoolArg("-rpcssl");

20
src/db.cpp

@ -43,7 +43,7 @@ static void EnvShutdown()
{ {
printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno()); printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno());
} }
DbEnv(0).remove(GetDataDir().c_str(), 0); DbEnv(0).remove(GetDataDir().string().c_str(), 0);
} }
class CDBInit class CDBInit
@ -78,10 +78,10 @@ CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
{ {
if (fShutdown) if (fShutdown)
return; return;
string strDataDir = GetDataDir(); filesystem::path pathDataDir = GetDataDir();
filesystem::path pathLogDir(strDataDir + "/database"); filesystem::path pathLogDir = pathDataDir / "database";
filesystem::create_directory(pathLogDir); filesystem::create_directory(pathLogDir);
filesystem::path pathErrorFile(strDataDir + "/db.log"); filesystem::path pathErrorFile = pathDataDir / "db.log";
printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str()); printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str());
int nDbCache = GetArg("-dbcache", 25); int nDbCache = GetArg("-dbcache", 25);
@ -94,7 +94,7 @@ CDB::CDB(const char* pszFile, const char* pszMode) : pdb(NULL)
dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug
dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.set_flags(DB_AUTO_COMMIT, 1);
dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1);
ret = dbenv.open(strDataDir.c_str(), ret = dbenv.open(pathDataDir.string().c_str(),
DB_CREATE | DB_CREATE |
DB_INIT_LOCK | DB_INIT_LOCK |
DB_INIT_LOG | DB_INIT_LOG |
@ -1087,13 +1087,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
return DB_NEED_REWRITE; return DB_NEED_REWRITE;
if (nFileVersion < CLIENT_VERSION) // Update if (nFileVersion < CLIENT_VERSION) // Update
{
// Get rid of old debug.log file in current directory
if (nFileVersion <= 105 && !pszSetDataDir[0])
unlink("debug.log");
WriteVersion(CLIENT_VERSION); WriteVersion(CLIENT_VERSION);
}
return DB_LOAD_OK; return DB_LOAD_OK;
} }
@ -1176,10 +1170,10 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
mapFileUseCount.erase(wallet.strWalletFile); mapFileUseCount.erase(wallet.strWalletFile);
// Copy wallet.dat // Copy wallet.dat
filesystem::path pathSrc(GetDataDir() + "/" + wallet.strWalletFile); filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
filesystem::path pathDest(strDest); filesystem::path pathDest(strDest);
if (filesystem::is_directory(pathDest)) if (filesystem::is_directory(pathDest))
pathDest = pathDest / wallet.strWalletFile; pathDest /= wallet.strWalletFile;
try { try {
#if BOOST_VERSION >= 104000 #if BOOST_VERSION >= 104000

36
src/init.cpp

@ -307,11 +307,11 @@ bool AppInit2(int argc, char* argv[])
} }
#endif #endif
if (!fDebug && !pszSetDataDir[0]) if (!fDebug)
ShrinkDebugFile(); ShrinkDebugFile();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
printf("Default data directory %s\n", GetDefaultDataDir().c_str()); printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
if (GetBoolArg("-loadblockindextest")) if (GetBoolArg("-loadblockindextest"))
{ {
@ -322,13 +322,13 @@ bool AppInit2(int argc, char* argv[])
} }
// Make sure only a single bitcoin process is using the data directory. // Make sure only a single bitcoin process is using the data directory.
string strLockFile = GetDataDir() + "/.lock"; boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
FILE* file = fopen(strLockFile.c_str(), "a"); // empty lock file; created if it doesn't exist. FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
if (file) fclose(file); if (file) fclose(file);
static boost::interprocess::file_lock lock(strLockFile.c_str()); static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock()) if (!lock.try_lock())
{ {
ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().c_str()), _("Bitcoin"), wxOK|wxMODAL); ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().string().c_str()), _("Bitcoin"), wxOK|wxMODAL);
return false; return false;
} }
@ -584,20 +584,20 @@ bool AppInit2(int argc, char* argv[])
} }
#ifdef WIN32 #ifdef WIN32
string StartupShortcutPath() boost::filesystem::path StartupShortcutPath()
{ {
return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk"; return MyGetSpecialFolderPath(CSIDL_STARTUP, true) / "Bitcoin.lnk";
} }
bool GetStartOnSystemStartup() bool GetStartOnSystemStartup()
{ {
return filesystem::exists(StartupShortcutPath().c_str()); return filesystem::exists(StartupShortcutPath());
} }
bool SetStartOnSystemStartup(bool fAutoStart) bool SetStartOnSystemStartup(bool fAutoStart)
{ {
// If the shortcut exists already, remove it for updating // If the shortcut exists already, remove it for updating
remove(StartupShortcutPath().c_str()); boost::filesystem::remove(StartupShortcutPath());
if (fAutoStart) if (fAutoStart)
{ {
@ -633,7 +633,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
{ {
WCHAR pwsz[MAX_PATH]; WCHAR pwsz[MAX_PATH];
// Ensure that the string is ANSI. // Ensure that the string is ANSI.
MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().c_str(), -1, pwsz, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().string().c_str(), -1, pwsz, MAX_PATH);
// Save the link by calling IPersistFile::Save. // Save the link by calling IPersistFile::Save.
hres = ppf->Save(pwsz, TRUE); hres = ppf->Save(pwsz, TRUE);
ppf->Release(); ppf->Release();
@ -659,15 +659,15 @@ boost::filesystem::path GetAutostartDir()
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
char* pszConfigHome = getenv("XDG_CONFIG_HOME"); char* pszConfigHome = getenv("XDG_CONFIG_HOME");
if (pszConfigHome) return fs::path(pszConfigHome) / fs::path("autostart"); if (pszConfigHome) return fs::path(pszConfigHome) / "autostart";
char* pszHome = getenv("HOME"); char* pszHome = getenv("HOME");
if (pszHome) return fs::path(pszHome) / fs::path(".config/autostart"); if (pszHome) return fs::path(pszHome) / ".config" / "autostart";
return fs::path(); return fs::path();
} }
boost::filesystem::path GetAutostartFilePath() boost::filesystem::path GetAutostartFilePath()
{ {
return GetAutostartDir() / boost::filesystem::path("bitcoin.desktop"); return GetAutostartDir() / "bitcoin.desktop";
} }
bool GetStartOnSystemStartup() bool GetStartOnSystemStartup()
@ -692,13 +692,7 @@ bool GetStartOnSystemStartup()
bool SetStartOnSystemStartup(bool fAutoStart) bool SetStartOnSystemStartup(bool fAutoStart)
{ {
if (!fAutoStart) if (!fAutoStart)
{ boost::filesystem::remove(GetAutostartFilePath());
#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION >= 3
unlink(GetAutostartFilePath().string().c_str());
#else
unlink(GetAutostartFilePath().native_file_string().c_str());
#endif
}
else else
{ {
char pszExePath[MAX_PATH+1]; char pszExePath[MAX_PATH+1];

2
src/main.cpp

@ -1822,7 +1822,7 @@ FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszM
{ {
if (nFile == -1) if (nFile == -1)
return NULL; return NULL;
FILE* file = fopen(strprintf("%s/blk%04d.dat", GetDataDir().c_str(), nFile).c_str(), pszMode); FILE* file = fopen((GetDataDir() / strprintf("blk%04d.dat", nFile)).string().c_str(), pszMode);
if (!file) if (!file)
return NULL; return NULL;
if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w')) if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w'))

136
src/util.cpp

@ -22,7 +22,6 @@ map<string, vector<string> > mapMultiArgs;
bool fDebug = false; bool fDebug = false;
bool fPrintToConsole = false; bool fPrintToConsole = false;
bool fPrintToDebugger = false; bool fPrintToDebugger = false;
char pszSetDataDir[MAX_PATH] = "";
bool fRequestShutdown = false; bool fRequestShutdown = false;
bool fShutdown = false; bool fShutdown = false;
bool fDaemon = false; bool fDaemon = false;
@ -165,10 +164,8 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
if (!fileout) if (!fileout)
{ {
char pszFile[MAX_PATH+100]; boost::filesystem::path pathDebug = GetDataDir() / "debug.log";
GetDataDir(pszFile); fileout = fopen(pathDebug.string().c_str(), "a");
strlcat(pszFile, "/debug.log", sizeof(pszFile));
fileout = fopen(pszFile, "a");
if (fileout) setbuf(fileout, NULL); // unbuffered if (fileout) setbuf(fileout, NULL); // unbuffered
} }
if (fileout) if (fileout)
@ -768,101 +765,94 @@ void PrintExceptionContinue(std::exception* pex, const char* pszThread)
} }
#ifdef WIN32 #ifdef WIN32
string MyGetSpecialFolderPath(int nFolder, bool fCreate) boost::filesystem::path MyGetSpecialFolderPath(int nFolder, bool fCreate)
{ {
namespace fs = boost::filesystem;
char pszPath[MAX_PATH] = ""; char pszPath[MAX_PATH] = "";
if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate))
{ {
return pszPath; return fs::path(pszPath);
} }
else if (nFolder == CSIDL_STARTUP) else if (nFolder == CSIDL_STARTUP)
{ {
return string(getenv("USERPROFILE")) + "\\Start Menu\\Programs\\Startup"; return fs::path(getenv("USERPROFILE")) / "Start Menu" / "Programs" / "Startup";
} }
else if (nFolder == CSIDL_APPDATA) else if (nFolder == CSIDL_APPDATA)
{ {
return getenv("APPDATA"); return fs::path(getenv("APPDATA"));
} }
return ""; return fs::path("");
} }
#endif #endif
string GetDefaultDataDir() boost::filesystem::path GetDefaultDataDir()
{ {
namespace fs = boost::filesystem;
// Windows: C:\Documents and Settings\username\Application Data\Bitcoin // Windows: C:\Documents and Settings\username\Application Data\Bitcoin
// Mac: ~/Library/Application Support/Bitcoin // Mac: ~/Library/Application Support/Bitcoin
// Unix: ~/.bitcoin // Unix: ~/.bitcoin
#ifdef WIN32 #ifdef WIN32
// Windows // Windows
return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin"; return MyGetSpecialFolderPath(CSIDL_APPDATA, true) / "Bitcoin";
#else #else
fs::path pathRet;
char* pszHome = getenv("HOME"); char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0) if (pszHome == NULL || strlen(pszHome) == 0)
pszHome = (char*)"/"; pathRet = fs::path("/");
string strHome = pszHome; else
if (strHome[strHome.size()-1] != '/') pathRet = fs::path(pszHome);
strHome += '/';
#ifdef MAC_OSX #ifdef MAC_OSX
// Mac // Mac
strHome += "Library/Application Support/"; pathRet /= "Library" / "Application Support";
filesystem::create_directory(strHome.c_str()); filesystem::create_directory(pathRet);
return strHome + "Bitcoin"; return pathRet / "Bitcoin";
#else #else
// Unix // Unix
return strHome + ".bitcoin"; return pathRet / ".bitcoin";
#endif #endif
#endif #endif
} }
void GetDataDir(char* pszDir) const boost::filesystem::path &GetDataDir(bool fNetSpecific)
{
// pszDir must be at least MAX_PATH length.
int nVariation;
if (pszSetDataDir[0] != 0)
{
strlcpy(pszDir, pszSetDataDir, MAX_PATH);
nVariation = 0;
}
else
{ {
namespace fs = boost::filesystem;
static fs::path pathCached[2];
static CCriticalSection csPathCached;
static bool cachedPath[2] = {false, false};
fs::path &path = pathCached[fNetSpecific];
// This can be called during exceptions by printf, so we cache the // This can be called during exceptions by printf, so we cache the
// value so we don't have to do memory allocations after that. // value so we don't have to do memory allocations after that.
static char pszCachedDir[MAX_PATH]; if (cachedPath[fNetSpecific])
if (pszCachedDir[0] == 0) return path;
strlcpy(pszCachedDir, GetDefaultDataDir().c_str(), sizeof(pszCachedDir));
strlcpy(pszDir, pszCachedDir, MAX_PATH); LOCK(csPathCached);
nVariation = 1;
} if (mapArgs.count("-datadir")) {
if (fTestNet) path = mapArgs["-datadir"];
{ } else {
char* p = pszDir + strlen(pszDir); path = GetDefaultDataDir();
if (p > pszDir && p[-1] != '/' && p[-1] != '\\') if (fNetSpecific && GetBoolArg("-testnet", false))
*p++ = '/'; path /= "testnet";
strcpy(p, "testnet");
nVariation += 2;
}
static bool pfMkdir[4];
if (!pfMkdir[nVariation])
{
pfMkdir[nVariation] = true;
boost::filesystem::create_directory(pszDir);
}
} }
string GetDataDir() fs::create_directory(path);
{
char pszDir[MAX_PATH]; cachedPath[fNetSpecific]=true;
GetDataDir(pszDir); return path;
return pszDir;
} }
string GetConfigFile() boost::filesystem::path GetConfigFile()
{ {
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
fs::path pathConfigFile(GetArg("-conf", "bitcoin.conf")); fs::path pathConfigFile(GetArg("-conf", "bitcoin.conf"));
if (!pathConfigFile.is_complete()) pathConfigFile = fs::path(GetDataDir()) / pathConfigFile; if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile;
return pathConfigFile.string(); return pathConfigFile;
} }
bool ReadConfigFile(map<string, string>& mapSettingsRet, bool ReadConfigFile(map<string, string>& mapSettingsRet,
@ -871,20 +861,6 @@ bool ReadConfigFile(map<string, string>& mapSettingsRet,
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace pod = boost::program_options::detail; namespace pod = boost::program_options::detail;
if (mapSettingsRet.count("-datadir"))
{
if (fs::is_directory(fs::system_complete(mapSettingsRet["-datadir"])))
{
fs::path pathDataDir(fs::system_complete(mapSettingsRet["-datadir"]));
strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir));
}
else
{
return false;
}
}
fs::ifstream streamConfig(GetConfigFile()); fs::ifstream streamConfig(GetConfigFile());
if (!streamConfig.good()) if (!streamConfig.good())
return true; // No bitcoin.conf file is OK return true; // No bitcoin.conf file is OK
@ -907,18 +883,18 @@ bool ReadConfigFile(map<string, string>& mapSettingsRet,
return true; return true;
} }
string GetPidFile() boost::filesystem::path GetPidFile()
{ {
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
fs::path pathPidFile(GetArg("-pid", "bitcoind.pid")); fs::path pathPidFile(GetArg("-pid", "bitcoind.pid"));
if (!pathPidFile.is_complete()) pathPidFile = fs::path(GetDataDir()) / pathPidFile; if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
return pathPidFile.string(); return pathPidFile;
} }
void CreatePidFile(string pidFile, pid_t pid) void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
{ {
FILE* file = fopen(pidFile.c_str(), "w"); FILE* file = fopen(path.string().c_str(), "w");
if (file) if (file)
{ {
fprintf(file, "%d\n", pid); fprintf(file, "%d\n", pid);
@ -939,8 +915,8 @@ int GetFilesize(FILE* file)
void ShrinkDebugFile() void ShrinkDebugFile()
{ {
// Scroll debug.log if it's getting too big // Scroll debug.log if it's getting too big
string strFile = GetDataDir() + "/debug.log"; boost::filesystem::path pathLog = GetDataDir() / "debug.log";
FILE* file = fopen(strFile.c_str(), "r"); FILE* file = fopen(pathLog.string().c_str(), "r");
if (file && GetFilesize(file) > 10 * 1000000) if (file && GetFilesize(file) > 10 * 1000000)
{ {
// Restart the file with some of the end // Restart the file with some of the end
@ -949,7 +925,7 @@ void ShrinkDebugFile()
int nBytes = fread(pch, 1, sizeof(pch), file); int nBytes = fread(pch, 1, sizeof(pch), file);
fclose(file); fclose(file);
file = fopen(strFile.c_str(), "w"); file = fopen(pathLog.string().c_str(), "w");
if (file) if (file)
{ {
fwrite(pch, 1, nBytes, file); fwrite(pch, 1, nBytes, file);

16
src/util.h

@ -19,6 +19,8 @@ typedef int pid_t; /* define for windows compatiblity */
#include <string> #include <string>
#include <boost/thread.hpp> #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/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp> #include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/sync/interprocess_condition.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 fDebug;
extern bool fPrintToConsole; extern bool fPrintToConsole;
extern bool fPrintToDebugger; extern bool fPrintToDebugger;
extern char pszSetDataDir[MAX_PATH];
extern bool fRequestShutdown; extern bool fRequestShutdown;
extern bool fShutdown; extern bool fShutdown;
extern bool fDaemon; 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 char* psz, const char* mask);
bool WildcardMatch(const std::string& str, const std::string& mask); bool WildcardMatch(const std::string& str, const std::string& mask);
int GetFilesize(FILE* file); int GetFilesize(FILE* file);
void GetDataDir(char* pszDirRet); boost::filesystem::path GetDefaultDataDir();
std::string GetConfigFile(); const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
std::string GetPidFile(); boost::filesystem::path GetConfigFile();
void CreatePidFile(std::string pidFile, pid_t pid); 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); bool ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32 #ifdef WIN32
std::string MyGetSpecialFolderPath(int nFolder, bool fCreate); boost::filesystem::path MyGetSpecialFolderPath(int nFolder, bool fCreate);
#endif #endif
std::string GetDefaultDataDir();
std::string GetDataDir();
void ShrinkDebugFile(); void ShrinkDebugFile();
int GetRandInt(int nMax); int GetRandInt(int nMax);
uint64 GetRand(uint64 nMax); uint64 GetRand(uint64 nMax);

Loading…
Cancel
Save