xRead method

  1. @override
void xRead(
  1. Uint8List target,
  2. int fileOffset
)
override

Fill the target with bytes read from fileOffset.

If the file is not large enough to fullfill the read, a VfsException with an error code of SqlExtendedError.SQLITE_IOERR_SHORT_READ must be thrown. Additional, the rest of target must be filled with zeroes.

Safety warning: Target may be a direct view over native memory that must not be used after this function returns.

Implementation

@override
void xRead(Uint8List target, int fileOffset) {
  final bytesRead = readInto(target, fileOffset);

  if (bytesRead < target.length) {
    // Remaining buffer must be filled with zeroes.
    target.fillRange(bytesRead, target.length, 0);

    // And we need to return a short read error
    throw const VfsException(SqlExtendedError.SQLITE_IOERR_SHORT_READ);
  }
}