lzma 0.2.1 copy "lzma: ^0.2.1" to clipboard
lzma: ^0.2.1 copied to clipboard

outdatedDart 1 only

LZMA compression library.

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? #

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.
11
likes
0
pub points
79%
popularity

Publisher

unverified uploader

LZMA compression library.

Homepage

License

unknown (LICENSE)

Dependencies

fixnum

More

Packages that depend on lzma