Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 639 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
// Unix | // Unix | ||||
return pathRet / ".bitcoin"; | return pathRet / ".bitcoin"; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
} | } | ||||
static fs::path g_blocks_path_cache_net_specific; | static fs::path g_blocks_path_cache_net_specific; | ||||
static fs::path seederPathCachedNetSpecific; | |||||
static fs::path pathCached; | static fs::path pathCached; | ||||
static fs::path pathCachedNetSpecific; | static fs::path pathCachedNetSpecific; | ||||
static RecursiveMutex csPathCached; | static RecursiveMutex csPathCached; | ||||
const fs::path &GetBlocksDir() { | const fs::path &GetBlocksDir() { | ||||
LOCK(csPathCached); | LOCK(csPathCached); | ||||
fs::path &path = g_blocks_path_cache_net_specific; | fs::path &path = g_blocks_path_cache_net_specific; | ||||
Show All 14 Lines | const fs::path &GetBlocksDir() { | ||||
} | } | ||||
path /= BaseParams().DataDir(); | path /= BaseParams().DataDir(); | ||||
path /= "blocks"; | path /= "blocks"; | ||||
fs::create_directories(path); | fs::create_directories(path); | ||||
return path; | return path; | ||||
} | } | ||||
const fs::path &GetSeederDir() { | |||||
LOCK(csPathCached); | |||||
fs::path &path = seederPathCachedNetSpecific; | |||||
// Cache the path to avoid calling fs::create_directories on every call of | |||||
// this function | |||||
if (!path.empty()) { | |||||
return path; | |||||
} | |||||
if (gArgs.IsArgSet("-seederdir")) { | |||||
path = fs::system_complete(gArgs.GetArg("-seederdir", "")); | |||||
if (!fs::is_directory(path)) { | |||||
path = ""; | |||||
return path; | |||||
} | |||||
} else { | |||||
path = GetDataDir(false); | |||||
} | |||||
path /= BaseParams().DataDir(); | |||||
path /= "seeder"; | |||||
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; | ||||
// Cache the path to avoid calling fs::create_directories on every call of | // Cache the path to avoid calling fs::create_directories on every call of | ||||
// this function | // this function | ||||
if (!path.empty()) { | if (!path.empty()) { | ||||
return path; | return path; | ||||
Show All 28 Lines | const fs::path &GetDataDir(bool fNetSpecific) { | ||||
return path; | return path; | ||||
} | } | ||||
bool CheckDataDirOption() { | bool CheckDataDirOption() { | ||||
std::string datadir = gArgs.GetArg("-datadir", ""); | std::string datadir = gArgs.GetArg("-datadir", ""); | ||||
return datadir.empty() || fs::is_directory(fs::system_complete(datadir)); | return datadir.empty() || fs::is_directory(fs::system_complete(datadir)); | ||||
} | } | ||||
bool CheckSeederDirOption() { | |||||
std::string seederdir = gArgs.GetArg("-seederdir", ""); | |||||
return seederdir.empty() || | |||||
fs::is_directory(fs::system_complete(seederdir)); | |||||
} | |||||
void ClearDatadirCache() { | void ClearDatadirCache() { | ||||
LOCK(csPathCached); | LOCK(csPathCached); | ||||
pathCached = fs::path(); | pathCached = fs::path(); | ||||
pathCachedNetSpecific = fs::path(); | pathCachedNetSpecific = fs::path(); | ||||
g_blocks_path_cache_net_specific = fs::path(); | g_blocks_path_cache_net_specific = fs::path(); | ||||
seederPathCachedNetSpecific = fs::path(); | |||||
} | } | ||||
fs::path GetConfigFile(const std::string &confPath) { | fs::path GetConfigFile(const std::string &confPath) { | ||||
return AbsPathForConfigVal(fs::path(confPath), false); | return AbsPathForConfigVal(fs::path(confPath), false); | ||||
} | } | ||||
static std::string TrimString(const std::string &str, | static std::string TrimString(const std::string &str, | ||||
const std::string &pattern) { | const std::string &pattern) { | ||||
▲ Show 20 Lines • Show All 565 Lines • Show Last 20 Lines |