open static method
Implementation
static Future<Pager> open(String path) async {
final file = File(path);
// ⚠️ FileMode.write TRUNCATES the file on open!
// FileMode.append does NOT truncate; it creates if absent and
// supports setPosition + read + writeFrom for random access.
// This is the only Dart FileMode that gives O_RDWR|O_CREAT|~O_TRUNC
// semantics without platform-specific FFI.
//
// On Linux: O_RDWR | O_CREAT | O_APPEND (setPosition overrides O_APPEND
// for reads; writes via writeFrom go to the seeked position).
// On Windows: equivalent random-access + no-truncate behavior.
final raf = await file.open(mode: FileMode.append);
final pager = Pager._(path, raf);
// Compute existing page count from file size.
// Use integer division (not ceil) to avoid counting partial/corrupt pages.
final size = await raf.length();
pager._totalPages = size ~/ pageSize;
return pager;
}