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

outdatedDart 1 only

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

archive #

Build Status

Overview #

A Dart library to encode and decode various archive and compression formats.

The library has no reliance on dart:io, so it can be used for both server and web applications.

The archive library currently supports the following decoders:

  • Zip (Archive)
  • Tar (Archive)
  • ZLib [Inflate decompression]
  • GZip [Inflate decompression]
  • BZip2 [decompression]

And the following encoders:

  • Zip (Archive)
  • Tar (Archive)
  • ZLib [Deflate compression]
  • GZip [Deflate compression]
  • BZip2 [compression]

Sample #

Extract the contents of a Zip file, and encode the contents as a BZip2 compressed Tar file:

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;
    List<int> data = file.content;
    new File('out/' + filename)
          ..createSync(recursive: true)
          ..writeAsBytesSync(data);
  }

  // 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(filename + '.tbz');
  fp.writeAsBytesSync(tar_bz2);
}
820
likes
20
points
6.12M
downloads

Publisher

verified publisherloki3d.com

Weekly Downloads

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

Repository (GitHub)

Documentation

Documentation

License

unknown (license)

Dependencies

args, crypto, path

More

Packages that depend on archive

OSZAR »