read method

  1. @override
Future<ByteData> read()
override

Implementation

@override
Future<ByteData> read() async {
  ZipPackage? archive;
  try {
    archive = await ZipContainer(zip).archive;
  } on Exception catch (e, stacktrace) {
    Fimber.e("ZipLicenseContainer.read ERROR", ex: e, stacktrace: stacktrace);
    throw LcpException.container.openFailed;
  }
  ZipLocalFile? entry = archive?.entries[pathInZIP];
  if (entry != null) {
    return ZipStream(archive!, entry)
        .readData(start: 0, length: entry.uncompressedSize)
        .then((data) => data.toByteData())
        .onError((error, stackTrace) =>
            throw LcpException.container.readFailed(pathInZIP));
  } else {
    throw LcpException.container.fileNotFound(pathInZIP);
  }
}