extractArchiveToDisk function Null safety

void extractArchiveToDisk(
  1. Archive archive,
  2. String outputPath
)

Implementation

void extractArchiveToDisk(Archive archive, String outputPath) {
  final outDir = Directory(outputPath);
  if (!outDir.existsSync()) {
    outDir.createSync(recursive: true);
  }
  for (final file in archive.files) {
    final filePath = '$outputPath${Platform.pathSeparator}${file.name}';

    if (!file.isFile || !_isWithinOutputPath(outputPath, filePath)) {
      continue;
    }
    final f = File(filePath);
    f.parent.createSync(recursive: true);
    f.writeAsBytesSync(file.content as List<int>);
  }
}