readAllNative method
Reads the whole file into a native buffer, optionally from pool.
The caller owns the returned buffer and must NativeBuffer.dispose it or
release it to pool.
Implementation
Future<NativeBuffer> readAllNative({NativeBufferPool? pool}) async {
final length = await this.length;
final buffer = pool?.acquire(length) ?? NativeBuffer.allocate(length);
try {
final n = readIntoNative(0, buffer);
if (n != length) {
throw StateError('short native read: $n of $length');
}
return buffer;
} catch (_) {
pool?.release(buffer);
rethrow;
}
}