archive 2.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 98

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;
    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);
}

2.0.0

  • Moved version up for Dart 2 support.
  • Fixed an issue with file compression flags when decoding zip archives.
  • Fixed an issue with bzip2 decoding in production code.

1.0.33

  • Support the latest version of package:args.

1.0.30 - May 27, 2017

  • Add archive_io sub-package for supporting file streaming rather than storing everything in memory. This is a work-in-progress and under development.

1.0.29 - May 25, 2017

  • Fix issue with POSIX tar files.
  • Upgrade dependency on archive to >=1.0.0 <2.0.0

1.0.20 - Jun2 21, 2015

  • Improve performance decompressing large files in zip archives.

1.0.19 - February 23, 2014

  • Disable CRC verification by default when decoding archives.

1.0.18 - October 09, 2014

  • Add support for encoding uncompressed files in zip archives.

1.0.17 - April 25, 2014

  • Fix a bug in InputStream.

1.0.16 - March 02, 2014

  • Add stream support to Inflate decompression.

1.0.15 - February 16, 2014

  • Improved performance when writing large blocks.

1.0.14 - February 12, 2014

  • Misc updates and fixes.

1.0.13 - February 06, 2014

  • Added BZip2 encoder.

  • BREAKING CHANGE: File was renamed to ArchiveFile, to avoid conflicts with dart:io.

1.0.12 - February 04, 2014

  • Added BZip2 decoder.

1.0.11 - February 02, 2014

  • Changed InputStream to work with typed_data instead of List<int>, should reduce memory and increase performance.

1.0.10 - January 19, 2013

  • Renamed InputBuffer and OutputBuffer to InputStream and OutputStream, respectively.

  • Added readBits method to InputStream.

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);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  archive: "^2.0.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:archive/archive.dart';
  
Version Uploaded Documentation Archive
2.0.0 May 29, 2018 Go to the documentation of archive 2.0.0 Download archive 2.0.0 archive
1.0.33 Dec 13, 2017 Go to the documentation of archive 1.0.33 Download archive 1.0.33 archive
1.0.32 Oct 12, 2017 Go to the documentation of archive 1.0.32 Download archive 1.0.32 archive
1.0.31 Jun 28, 2017 Go to the documentation of archive 1.0.31 Download archive 1.0.31 archive
1.0.29 May 25, 2017 Go to the documentation of archive 1.0.29 Download archive 1.0.29 archive
1.0.28 Feb 6, 2017 Go to the documentation of archive 1.0.28 Download archive 1.0.28 archive
1.0.27 Nov 23, 2016 Go to the documentation of archive 1.0.27 Download archive 1.0.27 archive
1.0.26 Nov 17, 2016 Go to the documentation of archive 1.0.26 Download archive 1.0.26 archive
1.0.25 Aug 17, 2016 Go to the documentation of archive 1.0.25 Download archive 1.0.25 archive
1.0.24 Jun 6, 2016 Go to the documentation of archive 1.0.24 Download archive 1.0.24 archive

All 33 versions...

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
96 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
98
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:archive/archive.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.49.0 <3.0.0
args >=1.4.0 <2.0.0 1.4.3
crypto >=2.0.0 <3.0.0 2.0.5
path >=1.5.1 <2.0.0 1.6.1
Transitive dependencies
charcode 1.1.1
collection 1.14.10
convert 2.0.1
typed_data 1.1.5
Dev dependencies
test >=0.12.13 <1.0.0