Sets the gzip comment bitfield
This commit is contained in:
parent
928178716a
commit
3a1a6a94d2
@ -5,9 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js";
|
// import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js";
|
||||||
|
import gunzip from "zlibjs/bin/gunzip.min.js";
|
||||||
|
|
||||||
const Zlib = zlibAndGzip.Zlib;
|
// const Zlib = zlibAndGzip.Zlib;
|
||||||
|
const Zlib = gunzip.Zlib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gunzip operation
|
* Gunzip operation
|
||||||
@ -42,8 +44,8 @@ class Gunzip extends Operation {
|
|||||||
* @returns {File}
|
* @returns {File}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const gunzip = new Zlib.Gunzip(new Uint8Array(input));
|
const gzipObj = new Zlib.Gunzip(new Uint8Array(input));
|
||||||
return new Uint8Array(gunzip.decompress()).buffer;
|
return new Uint8Array(gzipObj.decompress()).buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import {COMPRESSION_TYPE, ZLIB_COMPRESSION_TYPE_LOOKUP} from "../lib/Zlib.mjs";
|
import {COMPRESSION_TYPE, ZLIB_COMPRESSION_TYPE_LOOKUP} from "../lib/Zlib.mjs";
|
||||||
import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js";
|
// import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js";
|
||||||
|
import gzip from "zlibjs/bin/gzip.min.js";
|
||||||
|
|
||||||
const Zlib = zlibAndGzip.Zlib;
|
const Zlib = gzip.Zlib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gzip operation
|
* Gzip operation
|
||||||
@ -73,12 +74,15 @@ class Gzip extends Operation {
|
|||||||
options.filename = filename;
|
options.filename = filename;
|
||||||
}
|
}
|
||||||
if (comment.length) {
|
if (comment.length) {
|
||||||
options.flags.fcommenct = true;
|
options.flags.comment = true;
|
||||||
options.comment = comment;
|
options.comment = comment;
|
||||||
}
|
}
|
||||||
|
const gzipObj = new Zlib.Gzip(new Uint8Array(input), options);
|
||||||
const gzip = new Zlib.Gzip(new Uint8Array(input), options);
|
const compressed = new Uint8Array(gzipObj.compress());
|
||||||
return new Uint8Array(gzip.compress()).buffer;
|
if (options.flags.comment) {
|
||||||
|
compressed[3] |= 0x10;
|
||||||
|
}
|
||||||
|
return compressed.buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user