# CommonsCompressEts **Repository Path**: wangyingjun01/CommonsCompressEts ## Basic Information - **Project Name**: CommonsCompressEts - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 34 - **Created**: 2022-03-22 - **Last Updated**: 2022-03-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## EtsCommonsCompress Commons Compress组件对应相关功能压缩/解压功能组件 ### zip压缩功能 指定文件夹路径压缩文件夹zip方法 ``` javascript /** * 指定文件夹路径压缩文件夹zip方法 * * @since 7 * @permission N * @param {string} path - folder path. * @param {string} newFolder -path and file name after the .zip file is generated. * @returns {void | Promise} no callback return Promise otherwise return void. * @throws {TypedError | Error} Parameter check failed */ export async function zipCompress(path: string, newFolder: string): Promise { var obj = {}; await dirFor(path, path, obj); var zip = new JSZip(); for (let objKey in obj) { zip.file(objKey, obj[objKey]); } const content = await zip.generateAsync({ type: "arraybuffer" }) const open = fileio.openSync(path.replace('/' + newFolder, '') + '/' + newFolder + '.zip', 0o102, 0o666) const bytesWritten = fileio.writeSync(open, content); fileio.closeSync(open); } ``` ### zip解压功能 zip解压方法 ``` javascript /** * zip解压方法 * * @since 7 * @permission N * @param {string} path - path and name of the decompressed .zip file. * @param {string} target -Decompress the package to a specified path. * @returns {void | Promise} no callback return Promise otherwise return void. * @throws {TypedError | Error} Parameter check failed */ export async function zipDeCompress(path, target?): Promise { try { // 使用os读取zip的buffer数据 let stat = fileio.statSync(path) let size = stat.size; let contentBuffer = new ArrayBuffer(size); const open = fileio.openSync(path, 0o2); fileio.readSync(open, contentBuffer); // 将二进制contentBuffer转换成zip对象,将zip对象中数据写入到指定目录 var zip = new JSZip(); let res = await zip.loadAsync(contentBuffer) let newPath = target; if (target == null) { newPath = await createNewFileName(path.replace(".zip", "")); } try { fileio.mkdirSync(newPath) } catch (err) { } for (let key in res.files) { if (res.files[key].dir) { try { fileio.mkdirSync(newPath + "/" + res.files[key].name) } catch (err) { } continue; } let content = await res.file(res.files[key].name).async("arraybuffer") let writer = fileio.openSync(newPath + "/" + res.files[key].name, 0o102, 0o666) let bytesWritten = fileio.writeSync(writer, content); fileio.closeSync(writer) } await fileio.close(open); return true; } catch (error) { return false } } ``` ### gzip压缩功能 指定文件路径压缩文件gz方法 ``` javascript /** * 指定文件路径压缩文件gz方法 * * @since 7 * @permission N * @param {string} path - path. * @param {string} dest -path and file name after the .gz file is generated. * @returns {void | Promise} no callback return Promise otherwise return void. * @throws {TypedError | Error} Parameter check failed */ export async function gzipFile(src: string, dest: string): Promise { fileio.stat(src) .then((stat) => { const buf = new ArrayBuffer(stat.size); const reader = fileio.openSync(src, 0o2); fileio.read(reader, buf, (err, readOut) => { if (!err) { const writer = fileio.openSync(dest, 0o102, 0o666); const options = { gzip: true, level: 9 } fileio.write(writer, pako.gzip(new Uint8Array(buf), options) .buffer, (err, bytesWritten) => { if (!err) { fileio.closeSync(writer); } }); fileio.closeSync(reader); } }); }) } ``` ### gzip解压功能 解压gz文件方法 ``` javascript /** * 解压gz文件方法 * * @since 7 * @permission N * @param {string} src - path and name of the decompressed .gz file. * @param {string} target -Decompress the package to a specified path. * @returns {void | Promise} no callback return Promise otherwise return void. * @throws {TypedError | Error} Parameter check failed */ export async function unGzipFile(src: string, target: string): Promise { const reader = fileio.openSync(src, 0o2); const stat = fileio.statSync(src); const buf = new ArrayBuffer(stat.size); const res = await fileio.read(reader, buf); const options = { gzip: true, level: 9 }; const data = pako.inflate(new Uint8Array(res.buffer), options); const writer = fileio.openSync(target, 0o102, 0o666); fileio.writeSync(writer, data.buffer); fileio.closeSync(writer); fileio.closeSync(reader); } ``` ### xz 压缩功能 指定文件夹路径压缩文件夹xz方法 ```javascript export async function testXZCreation(data: string): Promise { let input = new File(data, "/hello.txt"); let output = new File(data, "/hello.txt.xz"); let out:OutputStream = new OutputStream(); let input1:InputStream = new InputStream(); out.setFilePath(output.getPath()); input1.setFilePath(input.getPath()); let cos: CompressorOutputStream = new CompressorStreamFactory(false) .createCompressorOutputStream("xz", out) IOUtils.copy(input1, cos); cos.close(); input1.close() } ``` ### xz 解压功能 解压xz文件方法 ```javascript export async function unXZFileTest(data: string): Promise { let input = new File(data, "/hello.txt.xz"); let output = new File(data, "/hello1.txt"); let out: OutputStream = new OutputStream(); let input1: InputStream = new InputStream(); out.setFilePath(output.getPath()); input1.setFilePath(input.getPath()); let inputs: CompressorInputStream = new CompressorStreamFactory(false) .createCompressorInputStream2("xz", input1) IOUtils.copy(inputs, out); out.close(); input1.close(); } ``` ### z 解压功能 解压z文件方法 ```javascript export async function unZFileTest(data: string): Promise { let inputStream: InputStream = new InputStream(); inputStream.setFilePath(data + '/bla.tar.Z'); let fOut: OutputStream = new OutputStream(); fOut.setFilePath(data + '/bla.tar'); let input:CompressorInputStream = new CompressorStreamFactory(false) .createCompressorInputStream2("z", inputStream); IOUtils.copy(input, fOut); inputStream.close(); fOut.close(); } ``` ### zstd 压缩功能 指定文件夹路径压缩文件夹zstd方法 ```javascript export async function testZstdCompressed(data: string): Promise { let compressor = new ZstdCompressor(); let output = new File(data, "/hello.txt.zst"); let input = new File(data, "/hello.txt"); let input1 = new InputStream(); let out = new OutputStream(); input1.setFilePath(input.getPath()); out.setFilePath(output.getPath()); original = new Int8Array(input1._endPosition) IOUtils.readFully(input1, original); let maxCompressLength: number = compressor .maxCompressedLength(original.length); compressed = new Int8Array(maxCompressLength); compressedSize = compressor.getZstdFrameCompress(original, 0, original.length, compressed, 0, compressed.length); out.writeBytes(compressed); out.close() input1.close(); } ``` ### zstd 解压功能 解压zstd文件方法 ```javascript export async function testZstdDecompressed(data: string, original: Int8Array , compressed: Int8Array, compressedSize: number): Promise { let compressor = new ZstdDecompressor(); let output = new File(data, "/newhello.txt"); let out = new OutputStream(); out.setFilePath(output.getPath()); let decompressed: Int8Array = new Int8Array(original.length); let compressedSize: number = compressor.decompress(compressed, 0, compressedSize, decompressed, 0, decompressed.length); out.writeBytes(decompressed) out.close() } ``` ### ar压缩功能 指定文件夹路径压缩文件夹ar方法 ```javascript export async function testArArchiveCreation(data: string, newFolder: string): Promise { let output: File = new File(data, newFolder + '.ar'); let file1: File = new File(data + '/' + newFolder, 'test1.xml'); let out: OutputStream = new OutputStream(); let input1: InputStream = new InputStream(); out.setFilePath(output.getPath()); input1.setFilePath(file1.getPath()); let os: ArchiveOutputStream = ArchiveStreamFactory .DEFAULT.createArchiveOutputStream("ar", out, ""); os.putArchiveEntry(new ArArchiveEntry("test1.xml", Long.fromNumber(file1.length()), 0, 0,ArArchiveEntry.DEFAULT_MODE, Long.fromNumber(new Date().getTime() / 1000))); IOUtils.copy(input1, os); os.closeArchiveEntry(); os.close(); } ``` ### ar 解压功能 解压ar文件方法 ```javascript export async function testReadLongNamesBSD(data:string): Promise { let inFile: File = new File(data , "longfile_bsd.ar"); let input: InputStream = new InputStream(); input.setFilePath(inFile.getPath()); let s: ArArchiveInputStream = new ArArchiveInputStream(input); let tarArchiveEntry: ArchiveEntry = null; while ((tarArchiveEntry = s.getNextEntry()) != null) { let name: string = tarArchiveEntry.getName(); let tarFile: File = new File(data, name); if(name.indexOf('/') != -1) { try { let splitName:string = name.substring(0, name.lastIndexOf('/')); fileio.mkdirSync(data + '/' + splitName); } catch (err) { } } let fos: OutputStream = null; try { fos = new OutputStream(); fos.setFilePath(tarFile.getPath()) let read: number = -1; let buffer: Int8Array = new Int8Array(1024); while ((read = s.readBytes(buffer)) != -1) { fos.writeBytesOffset(buffer, 0, read); } } catch (e) { throw e; } finally { fos.close(); } } } ``` ### brotli解压功能 解压brotli文件方法 ```javascript export async function brotilTest(data:string): Promise { this.generateTextFile(data, '/bla.tar.br', compressData) let input = new File(data,"/bla.tar.br"); let output = new File(data, "/bla.tar"); let out: OutputStream = new OutputStream(); let input1: InputStream = new InputStream(); out.setFilePath(output.getPath()); input1.setFilePath(input.getPath()); let inputs:CompressorInputStream = new CompressorStreamFactory() .createCompressorInputStream2("br", input1) IOUtils.copy(inputs, out); out.close(); input1.close(); } ``` ### bzip2压缩功能 指定文件夹路径压缩文件夹bzip2方法 ```javascript export async function bzip2FileTest(data: string): Promise { let inputStream: InputStream = new InputStream(); inputStream.setFilePath(data + '/hello.txt'); let fOut: OutputStream = new OutputStream(); fOut.setFilePath(data + '/hello.txt.bz2'); let cos: CompressorOutputStream = new CompressorStreamFactory(false) .createCompressorOutputStream("bzip2", fOut); IOUtils.copy(inputStream, cos); cos.close(); inputStream.close(); } ``` ### bzip2解压功能 解压bzip2文件方法 ```javascript export async function unBzip2FileTest(data:string): Promise { let inputStream: InputStream = new InputStream(); inputStream.setFilePath(data + '/hello.txt.bz2'); let fOut: OutputStream = new OutputStream(); fOut.setFilePath(data + '/hello.txt'); let input:CompressorInputStream = new CompressorStreamFactory(false) .createCompressorInputStream2("bzip2", inputStream); IOUtils.copy(input, fOut); inputStream.close(); } ``` ### lz4压缩功能 指定文件路径压缩文件lz4方法 ``` javascript export async function lz4Compressed(src: string, dest: string): Promise{ let stat = fileio.statSync(src); let fd = fileio.openSync(src, 0o2); let buf = new ArrayBuffer(stat.size); fileio.readSync(fd, buf); let unitArray = new Uint8Array(buf) let compressed = LZ4.compress(unitArray) let arrayBuffer = new Uint8Array(compressed).buffer; //生成文件 let newpath = fileio.openSync(dest, 0o102, 0o666) fileio.writeSync(newpath, compressed.buffer); } ``` ### lz4解压功能 解压lz4文件方法 ``` javascript export async function lz4Decompressed(src: string, target: string): Promise { let stat = fileio.statSync(src); let fd = fileio.openSync(src, 0o2); let buf = new ArrayBuffer(stat.size); fileio.readSync(fd, buf) let unitArray = new Uint8Array(buf) let decompress = LZ4.decompress(unitArray) try{ let newpath = fileio.openSync(target, 0o102, 0o666) let num = fileio.writeSync(newpath, decompress.buffer); }catch(error){ console.log('decompressed error '+error) } } ``` ### lzma压缩功能 压缩文件lz4,seven7方法 ``` javascript public Code(inStream: InputStream, outStream: OutputStream, inSize: Long, outSize: Long, progress: ICodeProgress): void { this._needReleaseMFStream = false; try { this.SetStreams(inStream, outStream, inSize, outSize); while (true) { this.CodeOneBlock(this.processedInSize, this.processedOutSize, this.finished); if (this.finished[0]) return; if (progress != null) { progress.SetProgress(this.processedInSize[0], this.processedOutSize[0]); } } } finally { this.ReleaseStreams(); } } ``` ### lzma,seven7解压功能 解压lzma,seven7文件方法 ``` javascript public Code(inStream: InputStream, outStream: OutputStream, outSize: Long): boolean { this.m_RangeDecoder.SetStream(inStream); this.m_OutWindow.SetStream(outStream); this.Init(); let state: number = Base.StateInit(); let rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0; let nowPos64: number = 0; let prevByte: number = 0; while (outSize.lessThan(0) || outSize.gt(nowPos64)) { let posState: number = parseInt((nowPos64 & this.m_PosStateMask) + ''); if (this.m_RangeDecoder.DecodeBit(this.m_IsMatchDecoders, (state << Base.kNumPosStatesBitsMax) + posState) == 0) { let decoder2: Decoder2 = this.m_LiteralDecoder.GetDecoder(parseInt(nowPos64 + ''), prevByte); if (!Base.StateIsCharState(state)) prevByte = decoder2.DecodeWithMatchByte(this.m_RangeDecoder, this.m_OutWindow.GetByte(rep0)); else prevByte = decoder2.DecodeNormal(this.m_RangeDecoder); this.m_OutWindow.PutByte(prevByte); state = Base.StateUpdateChar(state); nowPos64++; } else { let len: number; if (this.m_RangeDecoder.DecodeBit(this.m_IsRepDecoders, state) == 1) { len = 0; if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG0Decoders, state) == 0) { if (this.m_RangeDecoder.DecodeBit(this.m_IsRep0LongDecoders, (state << Base.kNumPosStatesBitsMax) + posState) == 0) { state = Base.StateUpdateShortRep(state); len = 1; } } else { let distance: number; if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG1Decoders, state) == 0) distance = rep1; else { if (this.m_RangeDecoder.DecodeBit(this.m_IsRepG2Decoders, state) == 0) distance = rep2; else { distance = rep3; rep3 = rep2; } rep2 = rep1; } rep1 = rep0; rep0 = distance; } if (len == 0) { len = this.m_RepLenDecoder.Decode(this.m_RangeDecoder, posState) + Base.kMatchMinLen; state = Base.StateUpdateRep(state); } } else { rep3 = rep2; rep2 = rep1; rep1 = rep0; len = Base.kMatchMinLen + this.m_LenDecoder.Decode(this.m_RangeDecoder, posState); state = Base.StateUpdateMatch(state); let posSlot: number = this.m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(this.m_RangeDecoder); if (posSlot >= Base.kStartPosModelIndex) { let numDirectBits: number = (posSlot >> 1) - 1; rep0 = ((2 | (posSlot & 1)) << numDirectBits); if (posSlot < Base.kEndPosModelIndex) rep0 += BitTreeDecoder.ReverseDecode(this.m_PosDecoders, rep0 - posSlot - 1, this.m_RangeDecoder, numDirectBits); else { rep0 += (this.m_RangeDecoder.DecodeDirectBits( numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits); rep0 += this.m_PosAlignDecoder.ReverseDecode(this.m_RangeDecoder); if (rep0 < 0) { if (rep0 == -1) break; return false; } } } else rep0 = posSlot; } if (rep0 >= nowPos64 || rep0 >= this.m_DictionarySizeCheck) { // m_OutWindow.Flush(); return false; } this.m_OutWindow.CopyBlock(rep0, len); nowPos64 += len; prevByte = this.m_OutWindow.GetByte(0); } } this.m_OutWindow.Flush(); this.m_OutWindow.ReleaseStream(); this.m_RangeDecoder.ReleaseStream(); return true; } ``` ### snappy压缩功能 压缩文件sz方法 ``` javascript export async function snappyUncompress(path, newfolder, newfile, newfile1) { let newpath = path + '/' + newfolder + '/' + newfile + '.sz' let buf = getFileBuf(newpath) var uncompressed = snappyJS.uncompress(buf) let fd = fileio.openSync(path + '/' + newfile1, 0o102, 0o666); let num = await fileio.write(fd, uncompressed); fileio.closeSync(fd); } ``` ### tar压缩功能 压缩文件sz方法 ``` javascript constructor(os:OutputStream, blockSize:number, encoding:string) { super(); let realBlockSize:number; if (TarArchiveOutputStream.BLOCK_SIZE_UNSPECIFIED == blockSize) { realBlockSize = TarArchiveOutputStream.RECORD_SIZE; } else { realBlockSize = blockSize; } if (realBlockSize <=0 || realBlockSize % TarArchiveOutputStream.RECORD_SIZE != 0) { throw new IllegalArgumentException("Block size must be a multiple of 512 bytes. Attempt to use set size of " + blockSize); } this.countingOut = os; this.out = new FixedLengthBlockOutputStream(this.countingOut, TarArchiveOutputStream.RECORD_SIZE); this.encoding = encoding; this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding); this.recordBuf = new Int8Array(TarArchiveOutputStream.RECORD_SIZE); this.recordsPerBlock = realBlockSize / TarArchiveOutputStream.RECORD_SIZE; } ``` ### tar解压功能 解压sz文件方法 ``` javascript constructor(inputStream:InputStream, blockSize:number, recordSize:number, encoding:string, lenient:boolean) { super(); this.inputStream = inputStream; this.hasHitEOF = false; this.encoding = encoding; this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding); this.recordSize = recordSize; this.recordBuffer = new Int8Array(recordSize); this.blockSize = blockSize; this.lenient = lenient; } ``` ### snappy解压功能 解压sz文件方法 ``` javascript export async function snappyCompress(path, newfile) { let newpath = path + '/' + newfile let buf = getFileBuf(newpath) /* 压缩文件*/ var compressed = snappyJS.compress(buf) let fd = fileio.openSync(path + '/' + newfile + '.sz', 0o102, 0o666); let num = await fileio.write(fd, compressed); fileio.closeSync(fd); } ``` ### dump解压功能 解压dump文件方法 ``` javascript constructor(is:InputStream, encoding:string){ super() this.raw = new TapeInputStream(is); this.hasHitEOF = false; this.encoding = encoding; this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding); try { // read header, verify it's a dump archive. let headerBytes:Int8Array = this.raw.readRecord(); if (!DumpArchiveUtil.verify(headerBytes)) { throw new UnrecognizedFormatException(); } // get summary information this.summary = new DumpArchiveSummary(headerBytes, this.zipEncoding); // reset buffer with actual block size. this.raw.resetBlockSize(this.summary.getNTRec(), this.summary.isCompressed()); // allocate our read buffer. this.blockBuffer = new Int8Array(4 * DumpArchiveConstants.TP_SIZE); // skip past CLRI and BITS segments since we don't handle them yet. this.readCLRI(); this.readBITS(); } catch (ex) { throw new ArchiveException(ex.getMessage(), ex); } // put in a dummy record for the root node. let root:Dirent = new Dirent(2, 2, 4, "."); this.names.set(2, root); this.queue = new PriorityQueue() } ``` ### deflate压缩功能 压缩文件deflate方法 ``` javascript export async function DeflateFile(src: string, dest: string): Promise { try { let stat = fileio.statSync(src); const buf = new ArrayBuffer(stat.size); const reader = fileio.openSync(src, 0o2); fileio.readSync(reader, buf); const writer = fileio.openSync(dest, 0o102, 0o666); const options = { deflate: true, level: 9 }; fileio.writeSync(writer, pako.deflate(new Uint8Array(buf), options).buffer); fileio.closeSync(reader); fileio.closeSync(writer); return true; } catch (error) { return false; } } ``` ### deflate解压功能 解压文件deflate方法 ``` javascript export async function InflateFile(src: string, target: string): Promise { try { const reader = fileio.openSync(src, 0o2); const stat = fileio.statSync(src); const buf = new ArrayBuffer(stat.size); const res = await fileio.read(reader, buf); const options = { deflate: true, level: 9 }; const data = pako.inflate(new Uint8Array(res.buffer), options); const writer = fileio.openSync(target, 0o102, 0o666); fileio.writeSync(writer, data.buffer); fileio.closeSync(writer); fileio.closeSync(reader); return true; } catch (error) { return false; } } ``` ### cpio压缩功能 压缩文件cpio方法 ``` javascript constructor(out: OutputStream, format: number=CpioConstants.FORMAT_NEW, blockSize: number=CpioConstants.BLOCK_SIZE, encoding: string=CharsetNames.US_ASCII) { super() this.out = out; switch (format) { case CpioConstants.FORMAT_NEW: case CpioConstants.FORMAT_NEW_CRC: case CpioConstants.FORMAT_OLD_ASCII: case CpioConstants.FORMAT_OLD_BINARY: break; default: throw new IllegalArgumentException("Unknown format: " + format); } this.entryFormat = format; this.blockSize = blockSize; this.encoding = encoding; this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding); } ``` ### cpio解压功能 解压文件cpio方法 ``` javascript constructor(input: InputStream, blockSize: number, encoding: string) { super() this.input = input; if (blockSize <= 0) { throw new IllegalArgumentException("blockSize must be bigger than 0"); } this.blockSize = blockSize; this.encoding = encoding; this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding); } ``` ### API介绍 ##zip function zipDeCompress(path: string, target?: string): Promise; - 接口描述:zip解压方法 - 参数path:解压缩的.zip文件的路径和名称。 - 参数target:将包解压缩到指定路径(可选,不填写默认使用path的参数)。 function zipCompress(path: string, newFolder: string): Promise; - 接口描述:指定文件夹路径压缩文件夹zip方法 - 参数path:要压缩的文件夹路径。 - 参数newFolder:生成.zip文件后的路径和文件名。 ##gzip function gzipFile(src: string, dest: string): Promise; - 接口描述:指定文件路径压缩文件gz方法 - 参数path:要压缩的文件路径。 - 参数newFolder:生成.gz文件后的路径和文件名。 function unGzipFile(src: string, target: string): Promise; - 接口描述:解压gz文件方法 - 参数src:解压缩的.gz文件的路径和名称。 - 参数target:将包解压缩到指定路径。 ##xz export async function testXZCreation(data: string): Promise - 接口描述:指定文件夹路径压缩文件夹xz方法 - 参数data:要压缩的文件路径。 export async function unXZFileTest(data: string): Promise - 接口描述:解压xz文件方法 - 参数data:要解压的文件路径。 ##z export async function unZFileTest(data: string): Promise - 接口描述:解压z文件方法 - 参数data:要解压的文件路径。 ##zstd export async function testZstdCompressed(data: string): Promise - 接口描述:指定文件夹路径压缩文件夹zstd方法 - 参数data:要压缩的文件路径。 export async function testZstdDecompressed(data: string, original: Int8Array , compressed: Int8Array, compressedSize: number): Promise - 接口描述:解压zstd文件方法 - 参数data:要解压的文件路径。 - 参数original:要压缩的文件字节 - 参数compressed: 压缩的文件的流。 - 参数compressedSize::压缩的文件字节大小 ##ar export async function testArArchiveCreation(data: string, newFolder: string,): Promise - 接口描述:指定文件夹路径压缩文件夹ar方法 - 参数data:要压缩的文件路径。 - 参数newFolder:压缩的生成文件名称。 export async function testReadLongNamesBSD(data:string): Promise - 接口描述:解压ar文件方法 - 参数data:要解压的文件路径。 ##brotil export async function brotilTest(data:string): Promise - 接口描述:解压 brotil文件方法 - 参数data:要解压的文件路径。 ##bzip2 export async function bzip2FileTest(data: string): Promise - 接口描述:指定文件夹路径压缩文件夹bzip2方法 - 参数data:要压缩的文件路径。 export async function unBzip2FileTest(data:string): Promise - 接口描述:解压 bzip2文件方法 - 参数data:要解压的文件路径。 ##lz4 function lz4Compressed(src: string, dest: string): Promise; - 接口描述:指定文件路径压缩文件lz4方法 - 参数path:要压缩的文件路径。 - 参数dest:生成.lz4文件后的路径和文件名。 function unGzipFile(src: string, target: string): Promise; - 接口描述:解压lz4文件方法 - 参数src:解压缩的.lz4文件的路径和名称。 - 参数target:将包解压缩到指定路径。 ##lzma,seven7 public Code(inStream: InputStream, outStream: OutputStream, inSize: Long, outSize: Long, progress: ICodeProgress): void; - 接口描述:通过流的形式压缩文件lzma(sevev7)方法 - 参数inStream:目标输入流。 - 参数outStream:输出流。 - 参数inSize:输入流大小。 - 参数outSize:输出流大小。 - 参数progress:icode进展。 public Code(inStream: InputStream, outStream: OutputStream, outSize: Long): boolean; - 接口描述:通过流的形式解压lzma(sevev7)文件方法 - 参数inStream:目标输入流。 - 参数outStream:输出流。 - 参数outSize:输出流大小。 ##snappy function snappyCompress(path, newfile); - 接口描述:指定文件路径压缩文件sz方法 - 参数path:要压缩的文件路径。 - 参数newfile:生成.sz文件后的路径和文件名。 function unGzipFile(src: string, target: string): Promise; - 接口描述:解压sz文件方法 - 参数src:解压缩的.sz文件的路径和名称。 - 参数target:将包解压缩到指定路径。 ##ArchiveStreamFactory public createArchiveOutputStreamLittle(archiverName: string, out: OutputStream): ArchiveOutputStream; - 接口描述:指定压缩格式(tar,cpio,ar)生成该格式的OutputStream - 参数archiverName:压缩的格式。 - 参数out:输出流。 public createArchiveInputStreamLittle(archiverName: string, inputStream: InputStream): ArchiveInputStream - 接口描述:指定压缩格式(ar,dump)生成该格式的InputStream - 参数archiverName:压缩的格式。 - 参数inputStream:输入流。 ##tar new TarArchiveOutputStream(os:OutputStream, blockSize:number, encoding:string); - 接口描述:创建一个tar格式的输出流 - 参数os:要使用的输出流。 - 参数blockSize:块的大小。 - 参数encoding:用于文件名的编码的名称。 new TarArchiveInputStream(inputStream:InputStream, blockSize:number, recordSize:number, encoding:string, lenient:boolean); - 接口描述:创建一个tar格式的输入流 - 参数inputStream:要使用的输入流。 - 参数blockSize:块的大小。 - 参数recordSize:记录大小。 - 参数encoding:用于文件名的编码的名称。 - 参数lenient:布尔值。 ##dump new DumpArchiveInputStream(is:InputStream, encoding:string); - 接口描述:创建一个dump格式的输入流 - 参数is:要使用的输入流。 - 参数newfile:用于文件名的编码的名称。 ##deflate function DeflateFile(src: string, dest: string): Promise; - 接口描述:指定文件路径压缩文件deflate方法 - 参数path:要压缩的文件路径。 - 参数newfile:生成.sz文件后的路径和文件名。 function InflateFile(src: string, target: string): Promise ; - 接口描述:解压deflate文件方法 - 参数src:解压缩的.gz文件的路径和名称。 - 参数target:将包解压缩到指定路径。 ##cpio new CpioArchiveOutputStream(out: OutputStream, format: number=CpioConstants.FORMAT_NEW, blockSize: number=CpioConstants.BLOCK_SIZE, encoding: string=CharsetNames.US_ASCII); - 接口描述:创建一个cpio格式的输出流 - 参数out:要使用的输出流。 - 参数blockSize:块的大小。 - 参数format:版本。 - 参数encoding:用于文件名的编码的名称。 new CpioArchiveInputStream(input: InputStream, blockSize: number, encoding: string) ; - 接口描述:创建一个cpio格式的输入流 - 参数input:要使用的输入流。 - 参数blockSize:块的大小。 - 参数encoding:用于文件名的编码的名称。