15 if (!fs::is_directory(path)) {
23 if (fs::is_directory(path /
"wallets")) {
31 static bool IsBerkeleyBtree(
const fs::path& path)
35 boost::system::error_code ec;
36 if (fs::file_size(path, ec) < 4096)
return false;
39 if (!file.is_open())
return false;
41 file.seekg(12, std::ios::beg);
43 file.read((
char*) &data,
sizeof(data));
49 return data == 0x00053162 || data == 0x62310500;
55 const size_t offset = wallet_dir.string().size() + 1;
56 std::vector<fs::path> paths;
58 for (
auto it = fs::recursive_directory_iterator(wallet_dir); it != fs::recursive_directory_iterator(); ++it) {
61 const fs::path path = it->path().string().substr(offset);
63 if (it->status().type() == fs::directory_file && IsBerkeleyBtree(it->path() /
"wallet.dat")) {
65 paths.emplace_back(path);
66 }
else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && IsBerkeleyBtree(it->path())) {
67 if (it->path().filename() ==
"wallet.dat") {
76 paths.emplace_back(path);
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
fs::path GetWalletDir()
Get the path of the wallet directory.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
const fs::path & GetDataDir(bool fNetSpecific)
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.