archive 2.0.11

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

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]

2.0.11 - November 8, 2019 #

  • Set the default permission for ArchiveFile to something more reasonable (0644 -rw-r--r--)

2.0.10 - June 11, 2019 #

  • Fix for decoding empty zip files.

2.0.9 - May 16, 2019 #

  • Add isSymbolicLink and nameOfLinkedFile to ArchiveFile.
  • Fix for encoding empty files.

2.0.8 #

  • Fix zip isFile

2.0.7 #

  • Fix zip file attributes.

2.0.6 #

  • Support GNU tar long file names
  • Maintain unix file permissions in zip archives.

2.0.5 #

  • Use dart:io ZLibCodec when run from dart:io.

2.0.4 #

  • Fix InputStream when a Uint8ListView is used as input data.

2.0.3 #

  • Use Utf8 for reading strings in archive archive files, for filenames and comments.

2.0.2 #

  • Fixes for ZipFileEncoder.

2.0.1 #

  • Remove the use of part and part of in the main library.
  • Added ZipFileEncoder to encode files and directories using dart:io.
  • Added createArchiveFromDirectory function to create an Archive object from a dart:io Directory.

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';
import 'package:archive/archive_io.dart';

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

  // Decode the Zip file
  Archive archive = 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;
      File('out/' + filename)
        ..createSync(recursive: true)
        ..writeAsBytesSync(data);
    } else {
      Directory('out/' + filename)
        ..create(recursive: true);
    }
  }

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

  // Write the compressed tar file to disk.
  File fp = File('test.tbz');
  fp.writeAsBytesSync(tar_bz2);

  // Zip a directory to out.zip using the zipDirectory convenience method
  var encoder = ZipFileEncoder();
  encoder.zipDirectory(Directory('out'), filename: 'out.zip');

  // Manually create a zip of a directory and individual files.
  encoder.create('out2.zip');
  encoder.addDirectory(Directory('out'));
  encoder.addFile(File('test.zip'));
  encoder.close();
}

Use this package as a library

1. Depend on it

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


dependencies:
  archive: ^2.0.11

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
98
Health:
Code health derived from static analysis. [more]
88
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/src/zlib/deflate.dart. (-4.89 points)

Analysis of lib/src/zlib/deflate.dart reported 10 hints, including:

line 1591 col 41: Avoid const keyword.

line 1624 col 41: Avoid const keyword.

line 1658 col 42: Avoid const keyword.

line 1680 col 37: Avoid const keyword.

line 1710 col 39: Avoid const keyword.

Fix lib/src/zlib/inflate.dart. (-3.45 points)

Analysis of lib/src/zlib/inflate.dart reported 7 hints, including:

line 348 col 51: Avoid const keyword.

line 642 col 50: Avoid const keyword.

line 684 col 35: Avoid const keyword.

line 707 col 47: Avoid const keyword.

line 740 col 48: Avoid const keyword.

Fix lib/src/bzip2/bzip2.dart. (-1.99 points)

Analysis of lib/src/bzip2/bzip2.dart reported 4 hints:

line 14 col 42: Avoid const keyword.

line 18 col 45: Avoid const keyword.

line 27 col 38: Avoid const keyword.

line 29 col 45: Avoid const keyword.

Fix additional 14 files with analysis or formatting issues. (-2 points)

Additional issues in the following files:

  • lib/src/bzip2/bz2_bit_reader.dart (1 hint)
  • lib/src/bzip2_decoder.dart (1 hint)
  • lib/src/bzip2_encoder.dart (1 hint)
  • lib/src/util/crc32.dart (1 hint)
  • lib/src/io/input_file_stream.dart (Run dartfmt to format lib/src/io/input_file_stream.dart.)
  • lib/src/io/tar_file_encoder.dart (Run dartfmt to format lib/src/io/tar_file_encoder.dart.)
  • lib/src/tar/tar_command.dart (Run dartfmt to format lib/src/tar/tar_command.dart.)
  • lib/src/util/archive_exception.dart (Run dartfmt to format lib/src/util/archive_exception.dart.)
  • lib/src/util/input_stream.dart (Run dartfmt to format lib/src/util/input_stream.dart.)
  • lib/src/util/mem_ptr.dart (Run dartfmt to format lib/src/util/mem_ptr.dart.)
  • lib/src/zip/zip_directory.dart (Run dartfmt to format lib/src/zip/zip_directory.dart.)
  • lib/src/zip_decoder.dart (Run dartfmt to format lib/src/zip_decoder.dart.)
  • lib/src/zip_encoder.dart (Run dartfmt to format lib/src/zip_encoder.dart.)
  • lib/src/zlib/_zlib_decoder_js.dart (Run dartfmt to format lib/src/zlib/_zlib_decoder_js.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.5.2
crypto >=2.0.0 <3.0.0 2.1.4
path >=1.5.1 <2.0.0 1.6.4
Transitive dependencies
charcode 1.1.2
collection 1.14.12
convert 2.1.1
typed_data 1.1.6
Dev dependencies
build_runner >=0.8.10 <2.0.0
build_web_compilers >=0.3.6 <2.0.0
pedantic ^1.0.0
test >=0.12.13 <2.0.0