inspect static method

Future<ZipInspection> inspect(
  1. String zipFilePath
)

Implementation

static Future<ZipInspection> inspect(String zipFilePath) async {
  final decoded = await _decodeAndValidate(zipFilePath);
  try {
    final manifestEntry = decoded.archive.files.singleWhere(
      (entry) => entry.name == OPENTOOL_FILE_JSON_NAME,
    );
    final bytes = manifestEntry.readBytes();
    if (bytes == null) throw const FormatException('Manifest is unreadable');
    final value = jsonDecode(utf8.decode(bytes));
    if (value is! Map<String, dynamic>) {
      throw const FormatException('Manifest must be a JSON object');
    }
    return ZipInspection(manifest: value, files: decoded.files);
  } finally {
    await decoded.close();
  }
}