Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/sqlite.cpp
Show First 20 Lines • Show All 746 Lines • ▼ Show 20 Lines | bool IsSQLiteFile(const fs::path &path) { | ||||
// Application id is at offset 68 and 4 bytes long | // Application id is at offset 68 and 4 bytes long | ||||
file.seekg(68, std::ios::beg); | file.seekg(68, std::ios::beg); | ||||
char app_id[4]; | char app_id[4]; | ||||
file.read(app_id, 4); | file.read(app_id, 4); | ||||
file.close(); | file.close(); | ||||
// Check the magic, see https://sqlite.org/fileformat2.html | // Check the magic, see https://sqlite.org/fileformat2.html | ||||
std::string magic_str(magic); | std::string magic_str(magic, 16); | ||||
if (magic_str != std::string("SQLite format 3")) { | if (magic_str != std::string("SQLite format 3", 16)) { | ||||
return false; | return false; | ||||
} | } | ||||
// Check the application id matches our network magic | // Check the application id matches our network magic | ||||
return memcmp(Params().DiskMagic().data(), app_id, 4) == 0; | return memcmp(Params().DiskMagic().data(), app_id, 4) == 0; | ||||
} | } |