v0.0.2
CI/CD / build-deploy (pull_request) Successful in 14s

This commit is contained in:
Timi
2026-04-01 22:47:09 +08:00
parent a24b1855aa
commit 56dec33c94
17 changed files with 550 additions and 69 deletions
@@ -1,6 +1,7 @@
package com.imyeyu.compress;
import com.imyeyu.io.IO;
import com.imyeyu.java.bean.CallbackArg;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
@@ -16,20 +17,49 @@ import java.io.OutputStream;
* @author 夜雨
* @version 2024-06-30 19:47
*/
public class GZipDecompressor extends Decompressor {
public class GZipDecompressor extends Decompressor<GZipDecompressor> {
/**
* 静态执行解压
*
* @param fromPath 源压缩文件路径
* @param toPath 目标目录路径
* @return 当前解压器
* @throws Exception 解压失败
*/
public static GZipDecompressor run(String fromPath, String toPath) throws Exception {
return run(fromPath, toPath, null, null);
}
/**
* 静态执行解压
*
* @param fromPath 源压缩文件路径
* @param toPath 目标目录路径
* @param fileCallback 文件处理回调
* @param progressCallback 进度回调
* @return 当前解压器
* @throws Exception 解压失败
*/
public static GZipDecompressor run(String fromPath, String toPath, CallbackArg<File> fileCallback, CallbackArg<Double> progressCallback) throws Exception {
return new GZipDecompressor()
.fileCallback(fileCallback)
.progressCallback(progressCallback)
.run(IO.file(fromPath), toPath);
}
@Override
public void run(File fromFile, String toPath) throws Exception {
protected void doRunFromFile(File fromFile, String toPath) throws Exception {
initByteProgress(readTotalSize(fromFile));
try {
super.run(fromFile, toPath);
super.doRunFromFile(fromFile, toPath);
} finally {
resetProgress();
}
}
@Override
public void run(InputStream fromStream, String toPath) throws Exception {
protected void doRun(InputStream fromStream, String toPath) throws Exception {
try (
GzipCompressorInputStream gzipInputStream = new GzipCompressorInputStream(nonClosing(fromStream));
TarArchiveInputStream tarInputStream = new TarArchiveInputStream(gzipInputStream)