sevenz-rust
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

Crate Documentation

This project is a 7z compressor/decompressor written in pure rust.
And it's very much inspired by the apache commons-compress project.

Decompression

Supported codecs:

  • [x] COPY
  • [x] LZMA
  • [x] LZMA2

Supported filters:

  • [x] BCJ X86
  • [x] BCJ PPC
  • [x] BCJ IA64
  • [x] BCJ ARM
  • [x] BCJ ARM_THUMB
  • [x] BCJ SPARC
  • [x] DELTA

The dependence of lzma-rs was removed sine 0.1.3.
The LZMA/LZMA2 decoder and all filters code was ported from tukaani xz for java

Usage

npm i sevenz-rust

deompress

import * as sevenz from "sevenz-rust";
sevenz.decompress(srcBytes:Array,password:string, callback)

index.js

import * as sevenz from "sevenz-rust";

// wasm.decompress();
function onFileChange(fileInput) {
    console.log(fileInput.files)
    var fileByteArray = [];
    var file = fileInput.files[0]
    if (!file) return
    var reader = new FileReader();
    reader.readAsArrayBuffer(file);
    reader.onloadend = function (evt) {
      if (evt.target.readyState == FileReader.DONE) {
        var arrayBuffer = evt.target.result,
          array = new Uint8Array(arrayBuffer);
        for (var i = 0; i < array.length; i++) {
          fileByteArray.push(array[i]);
        }
        console.log("file len=", fileByteArray.length)
        // decompress no password
        sevenz.decompress(fileByteArray,"", function(name, data){
            console.log("-", name, data.length)
        });
        console.log("done")
      }
    }
  }

  window.onFileChange = onFileChange;

index.html

<label>File:
    <input type="file" onchange="onFileChange(this)"></input>
  </label>

Package Sidebar

Install

npm i sevenz-rust

Weekly Downloads

0

Version

0.1.7

License

Apache-2.0

Unpacked Size

184 kB

Total Files

7

Last publish

Collaborators

  • dyz1990