extractArchiveToDiskSync function

void extractArchiveToDiskSync(
  1. Archive archive,
  2. String outputPath, {
  3. int? bufferSize,
  4. bool throwOnError = false,
  5. bool allowAbsoluteSymlinks = false,
  6. int? maxSize,
})

Writes the entries of archive into outputPath

With throwOnError a damaged entry throws ArchiveException, without it the entry is skipped and leaves no file

A truncated tar entry is detected only if archive was decoded with throwOnError or verify. Without them TarDecoder returns the bytes it read as a complete file, and that file is extracted without an error.

A symlink to an absolute path points outside outputPath, so it is skipped unless allowAbsoluteSymlinks is set

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

Implementation

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