18 if (!fs::is_directory(path)) {
27 if (fs::is_directory(path /
"wallets")) {
43 auto size = fs::file_size(path, ec);
45 LogPrintf(
"%s: %s %s\n", __func__, ec.message(),
52 std::ifstream file{path, std::ios::binary};
53 if (!file.is_open()) {
58 file.seekg(12, std::ios::beg);
61 file.read((
char *)&data,
sizeof(data));
67 return data == 0x00053162 || data == 0x62310500;
73 std::vector<fs::path> paths;
76 for (
auto it = fs::recursive_directory_iterator(wallet_dir, ec);
77 it != fs::recursive_directory_iterator(); it.increment(ec)) {
79 LogPrintf(
"%s: %s %s\n", __func__, ec.message(),
89 const auto path_str = it->path().native().substr(offset);
90 const fs::path path{path_str.begin(), path_str.end()};
92 if (it->status().type() == fs::file_type::directory &&
96 paths.emplace_back(path);
97 }
else if (it.depth() == 0 &&
98 it->symlink_status().type() == fs::file_type::regular &&
100 if (it->path().filename() ==
"wallet.dat") {
103 paths.emplace_back();
110 paths.emplace_back(path);
113 }
catch (
const std::exception &e) {
114 LogPrintf(
"%s: Error scanning %s: %s\n", __func__,
115 it->path().string(), e.what());
116 it.disable_recursion_pending();
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
fs::path GetWalletDir()
Get the path of the wallet directory.
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.
bool IsBerkeleyBtree(const fs::path &path)
Check format of database file.