readHeader static method
Read Header
Return (magic,version,type)
Implementation
static Future<(String, int, String)> readHeader(
String dbPath, {
String? requiredType,
int? requiredVersion,
}) async {
final file = File(dbPath);
if (!file.existsSync()) {
throw Exception('DB File Not Found!');
}
final raf = await file.open(mode: FileMode.read);
final (magic, version, type) = await BinaryRW.readHeader(raf);
if (requiredType != null) {
if (type != requiredType) {
throw Exception(
'Invalid DB Database `Type`: Excepted `$requiredType` Got `$type`',
);
}
}
if (requiredVersion != null) {
if (version != requiredVersion) {
throw Exception(
'Invalid DB Database `Version`: Excepted `$requiredVersion` Got `$version`',
);
}
}
return (type, version, type);
}