readAll method
Implementation
Future<List<WalBinRecord>> readAll({int afterLsn = 0}) async {
final file = File(path);
if (!await file.exists()) return [];
List<int> bytes;
try { bytes = await file.readAsBytes(); }
catch (_) { return []; }
final headerLen = const Utf8Encoder().convert(_fileVersion).length;
final result = <WalBinRecord>[];
int offset = headerLen;
while (offset < bytes.length) {
if (offset + 4 > bytes.length) break;
final bd = ByteData.sublistView(Uint8List.fromList(bytes));
final recordLen = bd.getUint32(offset, Endian.little);
offset += 4;
if (recordLen == 0 || offset + recordLen > bytes.length) break;
final rec = WalBinRecord.decode(
Uint8List.fromList(bytes.sublist(offset, offset + recordLen)), 0);
if (rec == null) break;
offset += recordLen;
offset += 4; // trailing length field
if (rec.lsn > afterLsn) result.add(rec);
}
return result;
}