lzma 0.3.0

dart-lzma is a port of LZMA compression algorithm to Dart.

The source code is a manual translation from the original Java version found on the LZMA SDK.

How to use it?

If you want to compress data then just call to the compress function:

import "package:lzma/lzma.dart" as LZMA;

var input = new LZMA.InStream(<PUT YOUR DATA BUFFER HERE>);
var output = new LZMA.OutStream();
LZMA.compress(input, output);

//output.data has now your compressed data

If you want to decompress data then just call to the decompress function:

import "package:lzma/lzma.dart" as LZMA;

var input = new LZMA.InStream(<PUT YOUR LZMA DATA BUFFER HERE>);
var output = new LZMA.OutStream();
LZMA.decompress(input, output);

//output.data has now your uncompressed data

Where:

  • input is the input data stream
  • output is the output data stream

Streams

Current stream classes will be change in the future.

Examples

Compress a file and write the result to another one:

import "dart:io";
import "package:lzma/lzma.dart" as LZMA;

void main(List<String> args) {
  if (args.length != 2) {
    print("Usage: compress input output");
    return;
  }

  var inFile = new File(args[0]);
  var outFile = new File(args[1]);

  var input = new LZMA.InStream(inFile.readAsBytesSync());
  var output = new LZMA.OutStream();

  LZMA.compress(input, output);

  outFile.writeAsBytesSync(output.data);
}

Decompress a file and write the result to another one:

import "dart:io";
import "package:lzma/lzma.dart" as LZMA;

void main(List<String> args) {
  if (args.length != 2) {
    print("Usage: decompress input output");
    return;
  }

  var inFile = new File(args[0]);
  var outFile = new File(args[1]);

  var input = new LZMA.InStream(inFile.readAsBytesSync());
  var output = new LZMA.OutStream();

  LZMA.decompress(input, output);

  outFile.writeAsBytesSync(output.data);
}

Performance

Be sure to run the library in production mode (not checked mode) with debugging disabled.

Limitations

  • Output data size is limited to 32 bits.

0.3.0 - Jan 25, 2014

  • Updated README.md, LICENSE.txt and CHANGELOG.md

0.2.1 - Nov 09, 2013

  • Updated README.md

0.2.0 - Nov 08, 2013

  • Added List<String> args to main function, Options class was removed from SDK
  • Used fixnum package from pub, removed local package
  • Fixed sublist parameters, now end is exclusive
  • Removed annoying "There is no such operator '>>' in num" warning
  • Ready for Dart 1.0.0!

0.1.3 - Mar 25, 2013

  • Updated fixnum library
  • Removed deprecated List.fixedLength constructor
  • Changed List.getRange for sublist

0.1.2 - Feb 01, 2013

  • Pre-M3 update

0.1.1 - Jan 18, 2013

  • Fixed some README.md tags
  • Added licenses directory
  • Added CHANGES.md

0.1.0 - Jan 17, 2013

  • First Dart pub package release

1. Depend on it

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

dependencies:
  lzma: "^0.3.0"

2. Install it

You can install packages from the command line:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:lzma/lzma.dart';

Platforms

About

LZMA compression library.

Author

Email jcmellado@gmail.com Juan Mellado

Homepage

code.google.com/p/dart-lzma/

Documentation

www.dartdocs.org/documentation/lzma/0.3.0/

Source code (hyperlinked)

www.crossdart.info/p/lzma/0.3.0/

Uploader

jcmellado@gmail.com

Published

Jan 25, 2014

Share