aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-10-19 17:16:51 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-10-19 17:16:51 +0000
commit5cbf75324d1509a1262b65c5073314a4da3f6d77 (patch)
treefcaaca0e6f71362c3968735b29ea8e2e7fff9dbb /util.cpp
parent2fad3d34b7b9bf03d56970cb36d9a091609b10c8 (diff)
downloadbitcoin-5cbf75324d1509a1262b65c5073314a4da3f6d77.tar.xz
Gavin's TEST network as -testnet switch, misc fixes
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@168 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/util.cpp b/util.cpp
index 5d81262e87..b7840841d1 100644
--- a/util.cpp
+++ b/util.cpp
@@ -16,6 +16,7 @@ bool fShutdown = false;
bool fDaemon = false;
bool fCommandLine = false;
string strMiscWarning;
+bool fTestNet = false;
@@ -649,15 +650,11 @@ string GetDefaultDataDir()
void GetDataDir(char* pszDir)
{
// pszDir must be at least MAX_PATH length.
+ int nVariation;
if (pszSetDataDir[0] != 0)
{
strlcpy(pszDir, pszSetDataDir, MAX_PATH);
- static bool fMkdirDone;
- if (!fMkdirDone)
- {
- fMkdirDone = true;
- filesystem::create_directory(pszDir);
- }
+ nVariation = 0;
}
else
{
@@ -665,11 +662,23 @@ void GetDataDir(char* pszDir)
// value so we don't have to do memory allocations after that.
static char pszCachedDir[MAX_PATH];
if (pszCachedDir[0] == 0)
- {
strlcpy(pszCachedDir, GetDefaultDataDir().c_str(), sizeof(pszCachedDir));
- filesystem::create_directory(pszCachedDir);
- }
strlcpy(pszDir, pszCachedDir, MAX_PATH);
+ nVariation = 1;
+ }
+ if (fTestNet)
+ {
+ char* p = pszDir + strlen(pszDir);
+ if (p > pszDir && p[-1] != '/' && p[-1] != '\\')
+ *p++ = '/';
+ strcpy(p, "testnet");
+ nVariation += 2;
+ }
+ static bool pfMkdir[4];
+ if (!pfMkdir[nVariation])
+ {
+ pfMkdir[nVariation] = true;
+ filesystem::create_directory(pszDir);
}
}