getFileCrc32 method

int getFileCrc32(
  1. ArchiveFile file
)
inherited

Implementation

int getFileCrc32(ArchiveFile file) {
  if (file.content == null) {
    return 0;
  }
  if (file.content is InputStreamBase) {
    final s = file.content as InputStreamBase;
    s.reset();
    var crc32 = 0;
    var size = s.length;
    Uint8List? bytes;
    const chunkSize = 1024 * 1024;
    while (size > chunkSize) {
      bytes = s.readBytes(chunkSize).toUint8List(bytes);
      crc32 = getCrc32(bytes, crc32);
      size -= chunkSize;
    }
    if (size > 0) {
      bytes = s.readBytes(size).toUint8List(bytes);
      crc32 = getCrc32(bytes, crc32);
    }
    file.content.reset();
    return crc32;
  }
  return getCrc32(file.content as List<int>);
}