15 std::vector<fs::path> paths;
16 boost::system::error_code ec;
18 for (
auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
20 if (fs::is_directory(*it)) {
30 const fs::path path{it->
path().lexically_relative(wallet_dir)};
32 if (it->status().type() == fs::directory_file &&
35 paths.emplace_back(path);
36 }
else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file &&
IsBDBFile(it->path())) {
37 if (it->path().filename() ==
"wallet.dat") {
46 paths.emplace_back(path);
49 }
catch (
const std::exception& e) {
60 if (fs::is_regular_file(wallet_path)) {
68 return wallet_path /
"wallet.dat";
74 return path /
"wallet.dat";
83 boost::system::error_code ec;
84 auto size = fs::file_size(path, ec);
86 if (size < 4096)
return false;
89 if (!file.is_open())
return false;
91 file.seekg(12, std::ios::beg);
93 file.read((
char*) &data,
sizeof(data));
99 return data == 0x00053162 || data == 0x62310500;
107 boost::system::error_code ec;
108 auto size = fs::file_size(path, ec);
110 if (size < 512)
return false;
113 if (!file.is_open())
return false;
117 file.read(magic, 16);
120 file.seekg(68, std::ios::beg);
122 file.read(app_id, 4);
127 std::string magic_str(magic, 16);
128 if (magic_str != std::string(
"SQLite format 3", 16)) {
133 return memcmp(
Params().MessageStart(), app_id, 4) == 0;
const CChainParams & Params()
Return the currently selected parameters.
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
path(boost::filesystem::path path)
fs::path SQLiteDataFile(const fs::path &path)
fs::path BDBDataFile(const fs::path &wallet_path)
bool IsBDBFile(const fs::path &path)
bool IsSQLiteFile(const fs::path &path)
std::vector< fs::path > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.