v0.0.3
All checks were successful
CI/CD / build-deploy (pull_request) Successful in 13s

This commit is contained in:
Timi
2026-04-02 16:23:53 +08:00
parent 56dec33c94
commit b56f4e8969
19 changed files with 372 additions and 282 deletions

View File

@@ -1,7 +1,6 @@
package com.imyeyu.compress;
import com.imyeyu.io.IO;
import com.imyeyu.java.bean.CallbackArg;
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
@@ -20,46 +19,47 @@ import java.nio.file.Path;
public class Z7Decompressor extends Decompressor<Z7Decompressor> {
/**
* 静态执行解压
* 创建解压
*
* @param fromPath 源压缩文件路径
* @param toPath 目标目录路径
* @return 当前解压器
* @throws Exception 解压失败
* @param fromFile 源压缩文件
* @return 解压器
*/
public static Z7Decompressor run(String fromPath, String toPath) throws Exception {
return run(fromPath, toPath, null, null);
public static Z7Decompressor of(File fromFile) {
return new Z7Decompressor().from(fromFile);
}
/**
* 静态执行解压
* 创建解压
*
* @param fromPath 源压缩文件路径
* @param toPath 目标目录路径
* @param fileCallback 文件处理回调
* @param progressCallback 进度回调
* @return 当前解压器
* @throws Exception 解压失败
* @return 解压器
*/
public static Z7Decompressor run(String fromPath, String toPath, CallbackArg<File> fileCallback, CallbackArg<Double> progressCallback) throws Exception {
return new Z7Decompressor()
.fileCallback(fileCallback)
.progressCallback(progressCallback)
.run(IO.file(fromPath), toPath);
public static Z7Decompressor of(String fromPath) {
return new Z7Decompressor().from(fromPath);
}
/**
* 创建解压器
*
* @param fromStream 源压缩输入流
* @return 解压器
*/
public static Z7Decompressor of(InputStream fromStream) {
return new Z7Decompressor().from(fromStream);
}
@Override
protected void doRunFromFile(File fromFile, String toPath) throws Exception {
protected void toPath(File fromFile, String toPath) throws Exception {
initByteProgress(readTotalSize(fromFile));
try {
super.doRunFromFile(fromFile, toPath);
super.toPath(fromFile, toPath);
} finally {
resetProgress();
}
}
@Override
protected void doRun(InputStream fromStream, String toPath) throws Exception {
protected void toPath(InputStream fromStream, String toPath) throws Exception {
Path tempFile = writeTempFile(fromStream);
try (SevenZFile file = SevenZFile.builder().setFile(tempFile.toFile()).get()) {
SevenZArchiveEntry entry;