unzipCheck function

bool unzipCheck(
  1. dynamic pathOrBytes,
  2. String destDir
)

Implementation

bool unzipCheck(dynamic pathOrBytes, String destDir) {
  Uint8List bytes;
  if (pathOrBytes is String) {
    String zipPath = pathOrBytes;
    zipPath = pathFullName(pathExpand(zipPath));
    destDir = pathFullName(pathExpand(destDir));
    bytes = dart_io.File(zipPath).readAsBytesSync();
  } else if (pathOrBytes is Uint8List) {
    bytes = pathOrBytes;
  } else {
    throw ArgumentError();
  }
  final archive = archive_archive.ZipDecoder().decodeBytes(bytes);
  for (final entry in archive) {
    if (entry.isFile) {
      var fileBytes = entry.readBytes();
      fileBytes = fileBytes!;
      if (isText(fileBytes)) {
        String text = dart_convert.utf8.decode(fileBytes);
        text = adjustTextNewlines(text);
        fileBytes = dart_convert.utf8.encode(text);
      }
      //writeFileBytes('$destDir/${entry.name}', fileBytes);
      if (!fileExists('$destDir/${entry.name}')) return false;
      var destBytes = readFileBytes('$destDir/${entry.name}');
      if (!identicalBinaries(fileBytes, destBytes)) return false;
    }
  }
  return true;
}