Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
Show First 20 Lines • Show All 533 Lines • ▼ Show 20 Lines | const fs::path &GetDataDir(bool fNetSpecific) { | ||||
LOCK(csPathCached); | LOCK(csPathCached); | ||||
fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached; | fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached; | ||||
// This can be called during exceptions by LogPrintf(), so we cache the | // This can be called during exceptions by LogPrintf(), 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. | ||||
if (!path.empty()) return path; | if (!path.empty()) return path; | ||||
if (IsArgSet("-datadir")) { | if (gArgs.IsArgSet("-datadir")) { | ||||
path = fs::system_complete(GetArg("-datadir", "")); | path = fs::system_complete(gArgs.GetArg("-datadir", "")); | ||||
if (!fs::is_directory(path)) { | if (!fs::is_directory(path)) { | ||||
path = ""; | path = ""; | ||||
return path; | return path; | ||||
} | } | ||||
} else { | } else { | ||||
path = GetDefaultDataDir(); | path = GetDefaultDataDir(); | ||||
} | } | ||||
if (fNetSpecific) path /= BaseParams().DataDir(); | if (fNetSpecific) path /= BaseParams().DataDir(); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (!streamConfig.good()) return; | ||||
} | } | ||||
} | } | ||||
// If datadir is changed in .conf file: | // If datadir is changed in .conf file: | ||||
ClearDatadirCache(); | ClearDatadirCache(); | ||||
} | } | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
fs::path GetPidFile() { | fs::path GetPidFile() { | ||||
fs::path pathPidFile(GetArg("-pid", BITCOIN_PID_FILENAME)); | fs::path pathPidFile(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME)); | ||||
if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; | if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; | ||||
return pathPidFile; | return pathPidFile; | ||||
} | } | ||||
void CreatePidFile(const fs::path &path, pid_t pid) { | void CreatePidFile(const fs::path &path, pid_t pid) { | ||||
FILE *file = fsbridge::fopen(path, "w"); | FILE *file = fsbridge::fopen(path, "w"); | ||||
if (file) { | if (file) { | ||||
fprintf(file, "%d\n", pid); | fprintf(file, "%d\n", pid); | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |