Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletutil.cpp
Show All 30 Lines | |||||
static bool IsBerkeleyBtree(const fs::path &path) { | static bool IsBerkeleyBtree(const fs::path &path) { | ||||
// A Berkeley DB Btree file has at least 4K. | // A Berkeley DB Btree file has at least 4K. | ||||
// This check also prevents opening lock files. | // This check also prevents opening lock files. | ||||
boost::system::error_code ec; | boost::system::error_code ec; | ||||
if (fs::file_size(path, ec) < 4096) { | if (fs::file_size(path, ec) < 4096) { | ||||
return false; | return false; | ||||
} | } | ||||
fs::ifstream file(path.string(), std::ios::binary); | fsbridge::ifstream file(path, std::ios::binary); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
return false; | return false; | ||||
} | } | ||||
// Magic bytes start at offset 12 | // Magic bytes start at offset 12 | ||||
file.seekg(12, std::ios::beg); | file.seekg(12, std::ios::beg); | ||||
uint32_t data = 0; | uint32_t data = 0; | ||||
// Read 4 bytes of file to compare against magic | // Read 4 bytes of file to compare against magic | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |