Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 1,102 Lines • ▼ Show 20 Lines | if (!CheckDataDirOption()) { | ||||
gArgs.GetArg("-datadir", "").c_str()); | gArgs.GetArg("-datadir", "").c_str()); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
std::string ArgsManager::GetChainName() const { | std::string ArgsManager::GetChainName() const { | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest"); | const bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest"); | ||||
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet"); | const bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet"); | ||||
const bool is_chain_arg_set = IsArgSet("-chain"); | |||||
if (fTestNet && fRegTest) { | |||||
throw std::runtime_error( | if (int(is_chain_arg_set) + int(fRegTest) + int(fTestNet) > 1) { | ||||
"Invalid combination of -regtest and -testnet."); | throw std::runtime_error("Invalid combination of -regtest, -testnet " | ||||
"and -chain. Can use at most one."); | |||||
} | } | ||||
if (fRegTest) { | if (fRegTest) { | ||||
return CBaseChainParams::REGTEST; | return CBaseChainParams::REGTEST; | ||||
} | } | ||||
if (fTestNet) { | if (fTestNet) { | ||||
return CBaseChainParams::TESTNET; | return CBaseChainParams::TESTNET; | ||||
} | } | ||||
return CBaseChainParams::MAIN; | return GetArg("-chain", CBaseChainParams::MAIN); | ||||
} | } | ||||
bool RenameOver(fs::path src, fs::path dest) { | bool RenameOver(fs::path src, fs::path dest) { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
return MoveFileExA(src.string().c_str(), dest.string().c_str(), | return MoveFileExA(src.string().c_str(), dest.string().c_str(), | ||||
MOVEFILE_REPLACE_EXISTING) != 0; | MOVEFILE_REPLACE_EXISTING) != 0; | ||||
#else | #else | ||||
int rc = std::rename(src.string().c_str(), dest.string().c_str()); | int rc = std::rename(src.string().c_str(), dest.string().c_str()); | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |