Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
Show First 20 Lines • Show All 669 Lines • ▼ Show 20 Lines | #ifdef MAC_OSX | ||||
return pathRet / "Library/Application Support/Bitcoin"; | return pathRet / "Library/Application Support/Bitcoin"; | ||||
#else | #else | ||||
// Unix | // Unix | ||||
return pathRet / ".bitcoin"; | return pathRet / ".bitcoin"; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
} | } | ||||
static fs::path g_blocks_path_cached; | |||||
static fs::path g_blocks_path_cache_net_specific; | |||||
static fs::path pathCached; | static fs::path pathCached; | ||||
static fs::path pathCachedNetSpecific; | static fs::path pathCachedNetSpecific; | ||||
static CCriticalSection csPathCached; | static CCriticalSection csPathCached; | ||||
const fs::path &GetBlocksDir(bool fNetSpecific) { | |||||
LOCK(csPathCached); | |||||
fs::path &path = | |||||
fNetSpecific ? g_blocks_path_cache_net_specific : g_blocks_path_cached; | |||||
// This can be called during exceptions by LogPrintf(), so we cache the | |||||
// value so we don't have to do memory allocations after that. | |||||
if (!path.empty()) return path; | |||||
jasonbcox: brackets | |||||
if (gArgs.IsArgSet("-blocksdir")) { | |||||
path = fs::system_complete(gArgs.GetArg("-blocksdir", "")); | |||||
if (!fs::is_directory(path)) { | |||||
path = ""; | |||||
return path; | |||||
} | |||||
} else { | |||||
path = GetDataDir(false); | |||||
} | |||||
if (fNetSpecific) path /= BaseParams().DataDir(); | |||||
jasonbcoxUnsubmitted Done Inline Actionsbrackets jasonbcox: brackets | |||||
path /= "blocks"; | |||||
fs::create_directories(path); | |||||
return path; | |||||
} | |||||
const fs::path &GetDataDir(bool fNetSpecific) { | 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()) { | if (!path.empty()) { | ||||
Show All 22 Lines | const fs::path &GetDataDir(bool fNetSpecific) { | ||||
return path; | return path; | ||||
} | } | ||||
void ClearDatadirCache() { | void ClearDatadirCache() { | ||||
LOCK(csPathCached); | LOCK(csPathCached); | ||||
pathCached = fs::path(); | pathCached = fs::path(); | ||||
pathCachedNetSpecific = fs::path(); | pathCachedNetSpecific = fs::path(); | ||||
g_blocks_path_cached = fs::path(); | |||||
g_blocks_path_cache_net_specific = fs::path(); | |||||
} | } | ||||
fs::path GetConfigFile(const std::string &confPath) { | fs::path GetConfigFile(const std::string &confPath) { | ||||
fs::path pathConfigFile(confPath); | fs::path pathConfigFile(confPath); | ||||
if (!pathConfigFile.is_complete()) { | if (!pathConfigFile.is_complete()) { | ||||
pathConfigFile = GetDataDir(false) / pathConfigFile; | pathConfigFile = GetDataDir(false) / pathConfigFile; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
brackets