Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/filesystem.cpp
- This file was added.
// Copyright (c) 2020 The Bitcoin developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#include <chainparamsbase.h> | |||||
#include <seeder/filesystem.h> | |||||
static fs::path seederPathCachedNetSpecific; | |||||
static RecursiveMutex csSeederPathCached; | |||||
const fs::path &GetSeederDir() { | |||||
LOCK(csSeederPathCached); | |||||
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; | |||||
} | |||||
bool CheckSeederDirOption() { | |||||
std::string seederdir = gArgs.GetArg("-seederdir", ""); | |||||
return seederdir.empty() || | |||||
fs::is_directory(fs::system_complete(seederdir)); | |||||
} |