Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
#ifdef HAVE_MALLOPT_ARENA_MAX | #ifdef HAVE_MALLOPT_ARENA_MAX | ||||
#include <malloc.h> | #include <malloc.h> | ||||
#endif | #endif | ||||
// Application startup time (used for uptime calculation) | // Application startup time (used for uptime calculation) | ||||
const int64_t nStartupTime = GetTime(); | const int64_t nStartupTime = GetTime(); | ||||
const char *const BITCOIN_CONF_FILENAME = "bitcoin.conf"; | const char *const BITCOIN_CONF_FILENAME = "bitcoin.conf"; | ||||
const char *const BITCOIN_PID_FILENAME = "bitcoind.pid"; | |||||
ArgsManager gArgs; | ArgsManager gArgs; | ||||
/** | /** | ||||
* A map that contains all the currently held directory locks. After successful | * A map that contains all the currently held directory locks. After successful | ||||
* locking, these will be held here until the global destructor cleans them up | * locking, these will be held here until the global destructor cleans them up | ||||
* and thus automatically unlocks them, or ReleaseDirectoryLocks is called. | * and thus automatically unlocks them, or ReleaseDirectoryLocks is called. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,001 Lines • ▼ Show 20 Lines | if (fRegTest) { | ||||
return CBaseChainParams::REGTEST; | return CBaseChainParams::REGTEST; | ||||
} | } | ||||
if (fTestNet) { | if (fTestNet) { | ||||
return CBaseChainParams::TESTNET; | return CBaseChainParams::TESTNET; | ||||
} | } | ||||
return CBaseChainParams::MAIN; | return CBaseChainParams::MAIN; | ||||
} | } | ||||
#ifndef WIN32 | |||||
fs::path GetPidFile() { | |||||
return AbsPathForConfigVal( | |||||
fs::path(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME))); | |||||
} | |||||
void CreatePidFile(const fs::path &path, pid_t pid) { | |||||
FILE *file = fsbridge::fopen(path, "w"); | |||||
if (file) { | |||||
fprintf(file, "%d\n", pid); | |||||
fclose(file); | |||||
} | |||||
} | |||||
#endif | |||||
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()); | ||||
return (rc == 0); | return (rc == 0); | ||||
#endif /* WIN32 */ | #endif /* WIN32 */ | ||||
▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines |