sevenz-rust
v0.1.7
Published
A 7z decompressor written in pure rust
Downloads
5
Readme
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>