This commit is contained in:
@@ -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.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
|
||||
@@ -22,36 +21,27 @@ import java.util.List;
|
||||
public class GZipCompressor extends Compressor<GZipCompressor> {
|
||||
|
||||
/**
|
||||
* 静态执行压缩
|
||||
* 创建压缩器
|
||||
*
|
||||
* @param fromPath 源路径
|
||||
* @param toPath 目标文件路径
|
||||
* @return 当前压缩器
|
||||
* @throws Exception 压缩失败
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static GZipCompressor run(String fromPath, String toPath) throws Exception {
|
||||
return run(fromPath, toPath, null, null);
|
||||
public static GZipCompressor of(String fromPath) {
|
||||
return new GZipCompressor().from(fromPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态执行压缩
|
||||
* 创建压缩器
|
||||
*
|
||||
* @param fromPath 源路径
|
||||
* @param toPath 目标文件路径
|
||||
* @param fileCallback 文件处理回调
|
||||
* @param progressCallback 进度回调
|
||||
* @return 当前压缩器
|
||||
* @throws Exception 压缩失败
|
||||
* @param fromFile 源文件
|
||||
* @return 压缩器
|
||||
*/
|
||||
public static GZipCompressor run(String fromPath, String toPath, CallbackArg<File> fileCallback, CallbackArg<Double> progressCallback) throws Exception {
|
||||
return new GZipCompressor()
|
||||
.fileCallback(fileCallback)
|
||||
.progressCallback(progressCallback)
|
||||
.run(fromPath, IO.file(toPath));
|
||||
public static GZipCompressor of(File fromFile) {
|
||||
return new GZipCompressor().from(fromFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun(String fromPath, OutputStream toStream) throws Exception {
|
||||
protected void toStream(String fromPath, OutputStream toStream) throws Exception {
|
||||
File fromFile = new File(fromPath);
|
||||
List<File> files = IO.listFile(fromFile);
|
||||
String basePath = files.getFirst().getParentFile().getAbsolutePath();
|
||||
|
||||
Reference in New Issue
Block a user