diff options
Diffstat (limited to 'src/wallet/db.cpp')
-rw-r--r-- | src/wallet/db.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 6437e1d7f0..0ed2658129 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -8,17 +8,22 @@ #include <logging.h> #include <wallet/db.h> +#include <exception> +#include <fstream> #include <string> +#include <system_error> +#include <vector> +namespace wallet { std::vector<fs::path> ListDatabases(const fs::path& wallet_dir) { std::vector<fs::path> paths; - boost::system::error_code ec; + std::error_code ec; for (auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) { if (ec) { if (fs::is_directory(*it)) { - it.no_push(); + it.disable_recursion_pending(); LogPrintf("%s: %s %s -- skipping.\n", __func__, ec.message(), fs::PathToString(it->path())); } else { LogPrintf("%s: %s %s\n", __func__, ec.message(), fs::PathToString(it->path())); @@ -29,11 +34,11 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir) try { const fs::path path{it->path().lexically_relative(wallet_dir)}; - if (it->status().type() == fs::directory_file && + if (it->status().type() == fs::file_type::directory && (IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) { // Found a directory which contains wallet.dat btree file, add it as a wallet. paths.emplace_back(path); - } else if (it.level() == 0 && it->symlink_status().type() == fs::regular_file && IsBDBFile(it->path())) { + } else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path())) { if (it->path().filename() == "wallet.dat") { // Found top-level wallet.dat btree file, add top level directory "" // as a wallet. @@ -48,7 +53,7 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir) } } catch (const std::exception& e) { LogPrintf("%s: Error scanning %s: %s\n", __func__, fs::PathToString(it->path()), e.what()); - it.no_push(); + it.disable_recursion_pending(); } } @@ -80,12 +85,12 @@ bool IsBDBFile(const fs::path& path) // A Berkeley DB Btree file has at least 4K. // This check also prevents opening lock files. - boost::system::error_code ec; + std::error_code ec; auto size = fs::file_size(path, ec); if (ec) LogPrintf("%s: %s %s\n", __func__, ec.message(), fs::PathToString(path)); if (size < 4096) return false; - fsbridge::ifstream file(path, std::ios::binary); + std::ifstream file{path, std::ios::binary}; if (!file.is_open()) return false; file.seekg(12, std::ios::beg); // Magic bytes start at offset 12 @@ -104,12 +109,12 @@ bool IsSQLiteFile(const fs::path& path) if (!fs::exists(path)) return false; // A SQLite Database file is at least 512 bytes. - boost::system::error_code ec; + std::error_code ec; auto size = fs::file_size(path, ec); if (ec) LogPrintf("%s: %s %s\n", __func__, ec.message(), fs::PathToString(path)); if (size < 512) return false; - fsbridge::ifstream file(path, std::ios::binary); + std::ifstream file{path, std::ios::binary}; if (!file.is_open()) return false; // Magic is at beginning and is 16 bytes long @@ -132,3 +137,4 @@ bool IsSQLiteFile(const fs::path& path) // Check the application id matches our network magic return memcmp(Params().MessageStart(), app_id, 4) == 0; } +} // namespace wallet |