archive 2.0.1 copy "archive: ^2.0.1" to clipboard
archive: ^2.0.1 copied to clipboard

outdated

Provides encoders and decoders for various archive and compression formats such as zip, tar, bzip2, gzip, and zlib.

example/example.dart

import 'dart:io';
import 'package:archive/archive.dart';

void main() {
  // Read the Zip file from disk.
  List<int> bytes = new File('test.zip').readAsBytesSync();

  // Decode the Zip file
  Archive archive = new ZipDecoder().decodeBytes(bytes);

  // Extract the contents of the Zip archive to disk.
  for (ArchiveFile file in archive) {
    String filename = file.name;
    if (file.isFile) {
      List<int> data = file.content;
      new File('out/' + filename)
        ..createSync(recursive: true)
        ..writeAsBytesSync(data);
    } else {
      new Directory('out/' + filename)
        ..create(recursive: true);
    }
  }

  // Encode the archive as a BZip2 compressed Tar file.
  List<int> tar_data = new TarEncoder().encode(archive);
  List<int> tar_bz2 = new BZip2Encoder().encode(tar_data);

  // Write the compressed tar file to disk.
  File fp = new File('test.tbz');
  fp.writeAsBytesSync(tar_bz2);
}
740
likes
0
pub points
99%
popularity

Publisher

verified publisherloki3d.com

Provides encoders and decoders for various archive and compression formats such as zip, tar, bzip2, gzip, and zlib.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

args, crypto, path

More

Packages that depend on archive