Initial project
This commit is contained in:
130
.gitignore
vendored
130
.gitignore
vendored
@ -1,98 +1,40 @@
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
# ---> Maven
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
# Eclipse m2e generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
/testOut*
|
||||
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
.idea/encodings.xml
generated
Normal file
7
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
56
pom.xml
Normal file
56
pom.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.imyeyu.compress</groupId>
|
||||
<artifactId>timi-compress</artifactId>
|
||||
<version>0.0.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.imyeyu.io</groupId>
|
||||
<artifactId>timi-io</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.26.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.tukaani</groupId>
|
||||
<artifactId>xz</artifactId>
|
||||
<version>1.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.10.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
66
src/main/java/com/imyeyu/compress/AbstractCompressor.java
Normal file
66
src/main/java/com/imyeyu/compress/AbstractCompressor.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.java.bean.CallbackArg;
|
||||
import com.imyeyu.utils.OS;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 抽象解压缩执行器
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2024-06-30 18:09
|
||||
*/
|
||||
public abstract class AbstractCompressor implements OS.FileSystem {
|
||||
|
||||
/** 操作文件回调 */
|
||||
protected CallbackArg<File> fileCallback;
|
||||
|
||||
/** 进度回调 */
|
||||
protected CallbackArg<Double> progressCallback;
|
||||
|
||||
/** 中止 */
|
||||
protected boolean isInterrupt = false;
|
||||
|
||||
/** 暂停 */
|
||||
protected boolean isPause = false;
|
||||
|
||||
/** 暂停锁 */
|
||||
protected final Object pauseLock = new Object();
|
||||
|
||||
/** 暂停 */
|
||||
public void pause() {
|
||||
isPause = true;
|
||||
}
|
||||
|
||||
/** 开始 */
|
||||
public void start() {
|
||||
isPause = false;
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
/** 中止 */
|
||||
public void interrupt() {
|
||||
isInterrupt = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置操作文件回调。正在压缩或解压某文件时触发
|
||||
*
|
||||
* @param fileCallback 回调接口
|
||||
*/
|
||||
public void setFileCallback(CallbackArg<File> fileCallback) {
|
||||
this.fileCallback = fileCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度回调
|
||||
*
|
||||
* @param progressCallback 回调接口
|
||||
*/
|
||||
public void setProgressCallback(CallbackArg<Double> progressCallback) {
|
||||
this.progressCallback = progressCallback;
|
||||
}
|
||||
}
|
||||
91
src/main/java/com/imyeyu/compress/CompressType.java
Normal file
91
src/main/java/com/imyeyu/compress/CompressType.java
Normal file
@ -0,0 +1,91 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import com.imyeyu.java.ref.Ref;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 压缩算法类型
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 18:03
|
||||
*/
|
||||
public enum CompressType {
|
||||
|
||||
/** 7z */
|
||||
Z7(Z7Compressor.class, Z7Decompressor.class, -0x51),
|
||||
|
||||
/** Zip */
|
||||
ZIP(ZipCompressor.class, ZipDecompressor.class, 0x504B0304),
|
||||
|
||||
/** Gzip */
|
||||
GZIP(GZipCompressor.class, GZipDecompressor.class, -0x74F7F8),
|
||||
|
||||
/** tar */
|
||||
TAR(TarCompressor.class, TarDecompressor.class, 0x776F7264);
|
||||
|
||||
/** 压缩类 */
|
||||
final Class<? extends Compressor> compressorType;
|
||||
|
||||
/** 解压类 */
|
||||
final Class<? extends Decompressor> decompressorType;
|
||||
|
||||
/** 文件头标记 */
|
||||
final int headHex;
|
||||
|
||||
CompressType(Class<? extends Compressor> compressorType, Class<? extends Decompressor> decompressorType, int headHex) {
|
||||
this.compressorType = compressorType;
|
||||
this.decompressorType = decompressorType;
|
||||
this.headHex = headHex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取压缩操作对象
|
||||
*
|
||||
* @return 压缩操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Compressor getCompressor() throws Exception {
|
||||
return Ref.newInstance(compressorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取解压操作对象
|
||||
*
|
||||
* @return 解压操作对象
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public Decompressor getDecompressor() throws Exception {
|
||||
return Ref.newInstance(decompressorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件获取解压操作对象。将会读取文件头解析算法类型
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 解压操作对象
|
||||
* @throws UnsupportedOperationException 不支持的文件
|
||||
* @throws Exception 实例化失败
|
||||
*/
|
||||
public static Decompressor fromFile(File file) throws Exception {
|
||||
InputStream is = IO.getInputStream(file);
|
||||
byte[] head = new byte[4];
|
||||
if (-1 == is.read(head)) {
|
||||
throw new UnsupportedOperationException("not support file");
|
||||
}
|
||||
is.close();
|
||||
int headHex = 0;
|
||||
for (byte b : head) {
|
||||
headHex <<= 8;
|
||||
headHex |= b;
|
||||
}
|
||||
for (CompressType type : values()) {
|
||||
if (type.headHex == headHex) {
|
||||
return type.getDecompressor();
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException("not support headHex");
|
||||
}
|
||||
}
|
||||
14
src/main/java/com/imyeyu/compress/Compressor.java
Normal file
14
src/main/java/com/imyeyu/compress/Compressor.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 10:34
|
||||
*/
|
||||
public abstract class Compressor extends AbstractCompressor {
|
||||
|
||||
public abstract void run(String fromPath, File toFile) throws Exception;
|
||||
}
|
||||
21
src/main/java/com/imyeyu/compress/Decompressor.java
Normal file
21
src/main/java/com/imyeyu/compress/Decompressor.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 抽象解压
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 18:02
|
||||
*/
|
||||
public abstract class Decompressor extends AbstractCompressor {
|
||||
|
||||
/**
|
||||
* 执行解压
|
||||
*
|
||||
* @param fromFile 来源压缩文件
|
||||
* @param toPath 解压路径
|
||||
* @throws Exception 解压失败
|
||||
*/
|
||||
public abstract void run(File fromFile, String toPath) throws Exception;
|
||||
}
|
||||
60
src/main/java/com/imyeyu/compress/GZipCompressor.java
Normal file
60
src/main/java/com/imyeyu/compress/GZipCompressor.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:40
|
||||
*/
|
||||
public class GZipCompressor extends Compressor {
|
||||
|
||||
@Override
|
||||
public void run(String fromPath, File toFile) throws Exception {
|
||||
List<File> files = IO.listFile(new File(fromPath));
|
||||
String basePath = files.getFirst().getParentFile().getAbsolutePath();
|
||||
|
||||
OutputStream os = IO.getOutputStream(toFile);
|
||||
BufferedOutputStream byteOS = new BufferedOutputStream(os);
|
||||
GzipCompressorOutputStream gzipOS = new GzipCompressorOutputStream(byteOS);
|
||||
TarArchiveOutputStream tarOS = new TarArchiveOutputStream(gzipOS);
|
||||
|
||||
TarArchiveEntry tarEntry;
|
||||
for (int i = 0, total = files.size(); i < total; i++) {
|
||||
String name = files.get(i).getAbsolutePath().substring(basePath.length() + 1);
|
||||
tarEntry = new TarArchiveEntry(files.get(i), name.replaceAll("\\\\", "/"));
|
||||
tarOS.putArchiveEntry(tarEntry);
|
||||
tarOS.write(IO.toBytes(files.get(i)));
|
||||
tarOS.closeArchiveEntry();
|
||||
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
if (progressCallback != null) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tarOS.finish();
|
||||
tarOS.close();
|
||||
gzipOS.finish();
|
||||
gzipOS.close();
|
||||
byteOS.flush();
|
||||
byteOS.close();
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
66
src/main/java/com/imyeyu/compress/GZipDecompressor.java
Normal file
66
src/main/java/com/imyeyu/compress/GZipDecompressor.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:47
|
||||
*/
|
||||
public class GZipDecompressor extends Decompressor {
|
||||
|
||||
@Override
|
||||
public void run(File fromFile, String toPath) throws Exception {
|
||||
InputStream is = IO.getInputStream(fromFile);
|
||||
GzipCompressorInputStream gzipIS = new GzipCompressorInputStream(is);
|
||||
TarArchiveInputStream tarIS = new TarArchiveInputStream(gzipIS);
|
||||
|
||||
int total = 0;
|
||||
{
|
||||
TarArchiveEntry entry;
|
||||
while ((entry = tarIS.getNextEntry()) != null) {
|
||||
if (!entry.isDirectory()) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
tarIS.close();
|
||||
is.close();
|
||||
|
||||
is = IO.getInputStream(fromFile);
|
||||
tarIS = new TarArchiveInputStream(is);
|
||||
TarArchiveEntry entry;
|
||||
for (int i = 0; (entry = tarIS.getNextEntry()) != null; i++) {
|
||||
String path = IO.fitPath(toPath) + entry.getName();
|
||||
if (entry.isDirectory()) {
|
||||
IO.dir(path);
|
||||
} else {
|
||||
File toFile = IO.file(path);
|
||||
IO.toFile(toFile, tarIS);
|
||||
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
}
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (progressCallback != null && total != -1) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tarIS.close();
|
||||
gzipIS.close();
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
61
src/main/java/com/imyeyu/compress/TarCompressor.java
Normal file
61
src/main/java/com/imyeyu/compress/TarCompressor.java
Normal file
@ -0,0 +1,61 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:48
|
||||
*/
|
||||
public class TarCompressor extends Compressor {
|
||||
|
||||
@Override
|
||||
public void run(String fromPath, File toFile) throws Exception {
|
||||
List<File> files = IO.listFile(new File(fromPath));
|
||||
String basePath = files.getFirst().getParentFile().getAbsolutePath();
|
||||
|
||||
OutputStream os = IO.getOutputStream(toFile);
|
||||
BufferedOutputStream byteOS = new BufferedOutputStream(os);
|
||||
TarArchiveOutputStream tarOS = new TarArchiveOutputStream(byteOS);
|
||||
|
||||
TarArchiveEntry tarEntry;
|
||||
for (int i = 0, total = files.size(); i < total; i++) {
|
||||
String name = files.get(i).getAbsolutePath().substring(basePath.length() + 1);
|
||||
tarEntry = new TarArchiveEntry(files.get(i), name.replaceAll("\\\\", "/"));
|
||||
tarOS.putArchiveEntry(tarEntry);
|
||||
tarOS.write(IO.toBytes(files.get(i)));
|
||||
tarOS.closeArchiveEntry();
|
||||
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
if (progressCallback != null) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tarOS.finish();
|
||||
tarOS.close();
|
||||
byteOS.flush();
|
||||
byteOS.close();
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
if (isInterrupt) {
|
||||
IO.destroy(toFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
63
src/main/java/com/imyeyu/compress/TarDecompressor.java
Normal file
63
src/main/java/com/imyeyu/compress/TarDecompressor.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:48
|
||||
*/
|
||||
public class TarDecompressor extends Decompressor {
|
||||
|
||||
@Override
|
||||
public void run(File fromFile, String toPath) throws Exception {
|
||||
InputStream is = IO.getInputStream(fromFile);
|
||||
TarArchiveInputStream tarIS = new TarArchiveInputStream(is);
|
||||
|
||||
int total = 0;
|
||||
{
|
||||
TarArchiveEntry entry;
|
||||
while ((entry = tarIS.getNextEntry()) != null) {
|
||||
if (!entry.isDirectory()) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
tarIS.close();
|
||||
is.close();
|
||||
|
||||
is = IO.getInputStream(fromFile);
|
||||
tarIS = new TarArchiveInputStream(is);
|
||||
TarArchiveEntry entry;
|
||||
for (int i = 0; (entry = tarIS.getNextEntry()) != null; i++) {
|
||||
String path = IO.fitPath(toPath) + entry.getName();
|
||||
if (entry.isDirectory()) {
|
||||
IO.dir(path);
|
||||
} else {
|
||||
File toFile = IO.file(path);
|
||||
IO.toFile(toFile, tarIS);
|
||||
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
}
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (progressCallback != null && total != -1) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tarIS.close();
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
50
src/main/java/com/imyeyu/compress/Z7Compressor.java
Normal file
50
src/main/java/com/imyeyu/compress/Z7Compressor.java
Normal file
@ -0,0 +1,50 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:40
|
||||
*/
|
||||
public class Z7Compressor extends Compressor {
|
||||
|
||||
@Override
|
||||
public void run(String fromPath, File toFile) throws Exception {
|
||||
List<File> files = IO.listFile(new File(fromPath));
|
||||
String basePath = files.getFirst().getParentFile().getAbsolutePath();
|
||||
|
||||
SevenZOutputFile out = new SevenZOutputFile(toFile);
|
||||
SevenZArchiveEntry entry;
|
||||
for (int i = 0, total = files.size(); i < total; i++) {
|
||||
String name = files.get(i).getAbsolutePath().substring(basePath.length() + 1);
|
||||
entry = out.createArchiveEntry(files.get(i), name.replaceAll("\\\\", "/"));
|
||||
out.putArchiveEntry(entry);
|
||||
out.write(IO.toBytes(files.get(i)));
|
||||
out.closeArchiveEntry();
|
||||
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
if (progressCallback != null) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
out.close();
|
||||
if (isInterrupt) {
|
||||
IO.destroy(toFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/main/java/com/imyeyu/compress/Z7Decompressor.java
Normal file
57
src/main/java/com/imyeyu/compress/Z7Decompressor.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:42
|
||||
*/
|
||||
public class Z7Decompressor extends Decompressor {
|
||||
|
||||
@Override
|
||||
public void run(File fromFile, String toPath) throws Exception {
|
||||
toPath = new File(toPath).getAbsolutePath() + SEP;
|
||||
|
||||
int total = 0;
|
||||
if (progressCallback != null) {
|
||||
SevenZFile file = SevenZFile.builder().setFile(fromFile).get();
|
||||
try (file) {
|
||||
while (file.getNextEntry() != null) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
SevenZFile file = SevenZFile.builder().setFile(fromFile).get();
|
||||
SevenZArchiveEntry entry;
|
||||
for (int i = 0; (entry = file.getNextEntry()) != null; i++) {
|
||||
if (entry.isDirectory()) {
|
||||
IO.dir(IO.fitPath(toPath) + entry.getName());
|
||||
} else {
|
||||
File toFile = IO.file(toPath + entry.getName());
|
||||
byte[] buffer = new byte[(int) entry.getSize()];
|
||||
file.read(buffer, 0, buffer.length);
|
||||
IO.toFile(toFile, buffer);
|
||||
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
}
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (progressCallback != null && total != -1) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
60
src/main/java/com/imyeyu/compress/ZipCompressor.java
Normal file
60
src/main/java/com/imyeyu/compress/ZipCompressor.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:46
|
||||
*/
|
||||
public class ZipCompressor extends Compressor {
|
||||
|
||||
@Override
|
||||
public void run(String fromPath, File toFile) throws Exception {
|
||||
List<File> files = IO.listFile(new File(fromPath));
|
||||
String basePath = files.getFirst().getParentFile().getAbsolutePath();
|
||||
|
||||
OutputStream os = IO.getOutputStream(toFile);
|
||||
BufferedOutputStream byteOS = new BufferedOutputStream(os);
|
||||
ZipOutputStream zipOS = new ZipOutputStream(byteOS);
|
||||
|
||||
for (int i = 0, total = files.size(); i < total; i++) {
|
||||
String name = files.get(i).getAbsolutePath().substring(basePath.length() + 1);
|
||||
ZipEntry zipEntry = new ZipEntry(name.replaceAll("\\\\", "/"));
|
||||
zipOS.putNextEntry(zipEntry);
|
||||
zipOS.write(IO.toBytes(files.get(i)));
|
||||
zipOS.closeEntry();
|
||||
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
if (progressCallback != null) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zipOS.finish();
|
||||
zipOS.close();
|
||||
byteOS.flush();
|
||||
byteOS.close();
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
if (isInterrupt) {
|
||||
IO.destroy(toFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/main/java/com/imyeyu/compress/ZipDecompressor.java
Normal file
56
src/main/java/com/imyeyu/compress/ZipDecompressor.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.imyeyu.compress;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 19:47
|
||||
*/
|
||||
public class ZipDecompressor extends Decompressor {
|
||||
|
||||
@Override
|
||||
public void run(File fromFile, String toPath) throws Exception {
|
||||
ZipFile zip = new ZipFile(fromFile);
|
||||
|
||||
Enumeration<? extends ZipEntry> entries = zip.entries();
|
||||
int total = 0;
|
||||
while (entries.hasMoreElements()) {
|
||||
if (!entries.nextElement().isDirectory()) {
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
entries = zip.entries();
|
||||
ZipEntry entry;
|
||||
for (int i = 0; entries.hasMoreElements(); i++) {
|
||||
entry = entries.nextElement();
|
||||
if (entry.isDirectory()) {
|
||||
IO.dir(IO.fitPath(toPath) + entry.getName());
|
||||
} else {
|
||||
File toFile = IO.file(IO.fitPath(toPath) + entry.getName());
|
||||
IO.toFile(toFile, zip.getInputStream(entry));
|
||||
|
||||
if (fileCallback != null) {
|
||||
fileCallback.handler(toFile);
|
||||
}
|
||||
}
|
||||
if (isPause) {
|
||||
synchronized (pauseLock) {
|
||||
pauseLock.wait();
|
||||
}
|
||||
}
|
||||
if (progressCallback != null) {
|
||||
progressCallback.handler(1D * i / total);
|
||||
}
|
||||
if (isInterrupt) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zip.close();
|
||||
}
|
||||
}
|
||||
21
src/test/java/test/ClearTest.java
Normal file
21
src/test/java/test/ClearTest.java
Normal file
@ -0,0 +1,21 @@
|
||||
package test;
|
||||
|
||||
import com.imyeyu.io.IO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 23:54
|
||||
*/
|
||||
public class ClearTest {
|
||||
|
||||
@Test
|
||||
public void clearTestFiles() throws Exception {
|
||||
IO.destroy(new File("testOut"));
|
||||
IO.dir("testOut");
|
||||
IO.destroy(new File("testOutDe"));
|
||||
IO.dir("testOutDe");
|
||||
}
|
||||
}
|
||||
27
src/test/java/test/GzipTest.java
Normal file
27
src/test/java/test/GzipTest.java
Normal file
@ -0,0 +1,27 @@
|
||||
package test;
|
||||
|
||||
import com.imyeyu.compress.CompressType;
|
||||
import com.imyeyu.io.IO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 17:54
|
||||
*/
|
||||
public class GzipTest {
|
||||
|
||||
@Test
|
||||
public void testCompress() throws Exception {
|
||||
File out = IO.file("testOut/test.gz");
|
||||
CompressType.Z7.getCompressor().run("testSrc", out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.gz");
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).run(in, out.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
27
src/test/java/test/TarTest.java
Normal file
27
src/test/java/test/TarTest.java
Normal file
@ -0,0 +1,27 @@
|
||||
package test;
|
||||
|
||||
import com.imyeyu.compress.CompressType;
|
||||
import com.imyeyu.io.IO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 17:54
|
||||
*/
|
||||
public class TarTest {
|
||||
|
||||
@Test
|
||||
public void testCompress() throws Exception {
|
||||
File out = IO.file("testOut/test.tar");
|
||||
CompressType.Z7.getCompressor().run("testSrc", out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.tar");
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).run(in, out.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
27
src/test/java/test/Z7Test.java
Normal file
27
src/test/java/test/Z7Test.java
Normal file
@ -0,0 +1,27 @@
|
||||
package test;
|
||||
|
||||
import com.imyeyu.compress.CompressType;
|
||||
import com.imyeyu.io.IO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 10:53
|
||||
*/
|
||||
public class Z7Test {
|
||||
|
||||
@Test
|
||||
public void testCompress() throws Exception {
|
||||
File out = IO.file("testOut/test.7z");
|
||||
CompressType.Z7.getCompressor().run("testSrc", out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.7z");
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).run(in, out.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
27
src/test/java/test/ZipTest.java
Normal file
27
src/test/java/test/ZipTest.java
Normal file
@ -0,0 +1,27 @@
|
||||
package test;
|
||||
|
||||
import com.imyeyu.compress.CompressType;
|
||||
import com.imyeyu.io.IO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @version 2024-06-30 17:54
|
||||
*/
|
||||
public class ZipTest {
|
||||
|
||||
@Test
|
||||
public void testCompress() throws Exception {
|
||||
File out = IO.file("testOut/test.zip");
|
||||
CompressType.Z7.getCompressor().run("testSrc", out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecompress() throws Exception {
|
||||
File in = IO.file("testOut/test.zip");
|
||||
File out = IO.dir("testOutDe");
|
||||
CompressType.fromFile(in).run(in, out.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
1
testSrc/file.txt
Normal file
1
testSrc/file.txt
Normal file
@ -0,0 +1 @@
|
||||
file test
|
||||
1
testSrc/subDir/subFile.txt
Normal file
1
testSrc/subDir/subFile.txt
Normal file
@ -0,0 +1 @@
|
||||
sub file test
|
||||
1
testSrc/subDir/subFile2.txt
Normal file
1
testSrc/subDir/subFile2.txt
Normal file
@ -0,0 +1 @@
|
||||
sub file test2
|
||||
Reference in New Issue
Block a user