extractArchiveToDiskSync function

void extractArchiveToDiskSync(
  1. Archive archive,
  2. String outputPath, {
  3. int? bufferSize,
  4. int? maxSize,
})

Writes the entries of archive into the directory outputPath.

An entry whose path or link target would land outside outputPath is skipped. Symbolic links are created after every other entry, and one that would lead through another link is skipped too.

maxSize limits the total size of the files written. An entry that would take it past that throws an ArchiveException before it is written. A zip entry is never decoded past the size the archive gives for it.

An entry whose content fails to decode throws, and its partial file is removed.

Implementation

void extractArchiveToDiskSync(
  Archive archive,
  String outputPath, {
  int? bufferSize,
  int? maxSize,
}) {
  final writer =
      EntryWriter(outputPath, bufferSize: bufferSize, maxSize: maxSize);
  for (final entry in archive) {
    writer.write(entry);
  }
  writer.finish();
}