Compare commits
1
Commits
dev
..
829790af29
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
829790af29 |
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.io</groupId>
|
<groupId>com.imyeyu.io</groupId>
|
||||||
<artifactId>timi-io</artifactId>
|
<artifactId>timi-io</artifactId>
|
||||||
<version>0.1.1</version>
|
<version>0.0.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -28,42 +28,10 @@
|
|||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>3.3.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok-maven-plugin</artifactId>
|
|
||||||
<version>1.18.20.0</version>
|
|
||||||
<configuration>
|
|
||||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
|
||||||
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
|
||||||
<addOutputDirectory>false</addOutputDirectory>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>delombok</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.36</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.11.2</version>
|
<version>3.11.2</version>
|
||||||
<configuration>
|
|
||||||
<sourcepath>${project.build.directory}/delombok</sourcepath>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
<docencoding>UTF-8</docencoding>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@@ -92,7 +60,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.utils</groupId>
|
<groupId>com.imyeyu.utils</groupId>
|
||||||
<artifactId>timi-utils</artifactId>
|
<artifactId>timi-utils</artifactId>
|
||||||
<version>0.1.1</version>
|
<version>0.0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.imyeyu.io;
|
package com.imyeyu.io;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.java.bean.ActionException;
|
|
||||||
import com.imyeyu.java.bean.Callback;
|
import com.imyeyu.java.bean.Callback;
|
||||||
import com.imyeyu.java.bean.CallbackArg;
|
import com.imyeyu.java.bean.CallbackArg;
|
||||||
import com.imyeyu.java.bean.ResultCode;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.utils.Decoder;
|
import com.imyeyu.utils.Decoder;
|
||||||
import com.imyeyu.utils.OS;
|
import com.imyeyu.utils.OS;
|
||||||
import com.imyeyu.utils.Text;
|
import com.imyeyu.utils.Text;
|
||||||
@@ -135,20 +134,6 @@ public class IO implements OS.FileSystem {
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File dir(String path, File def) {
|
|
||||||
if (TimiJava.isEmpty(path)) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
File dir = new File(path);
|
|
||||||
if (dir.exists()) {
|
|
||||||
if (dir.isFile()) {
|
|
||||||
return dir.getParentFile();
|
|
||||||
}
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件对象,如果不存在则创建该文件
|
* 获取文件对象,如果不存在则创建该文件
|
||||||
*
|
*
|
||||||
@@ -233,7 +218,7 @@ public class IO implements OS.FileSystem {
|
|||||||
if (file.renameTo(resultFile) && resultFile.exists()) {
|
if (file.renameTo(resultFile) && resultFile.exists()) {
|
||||||
return resultFile;
|
return resultFile;
|
||||||
}
|
}
|
||||||
throw new ActionException(ResultCode.RESULT_BAD, "rename file fail: from " + file.getAbsolutePath() + ", to " + resultFile.getAbsolutePath());
|
throw new TimiException(TimiCode.RESULT_BAD, "rename file fail: from " + file.getAbsolutePath() + ", to " + resultFile.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
String msg = "Illeagl file name: %s, not allow char: %s";
|
String msg = "Illeagl file name: %s, not allow char: %s";
|
||||||
if (OS.IS_WINDOWS) {
|
if (OS.IS_WINDOWS) {
|
||||||
@@ -661,7 +646,7 @@ public class IO implements OS.FileSystem {
|
|||||||
public static void toOutputStream(InputStream is, OutputStream os, long start, long end) throws IOException {
|
public static void toOutputStream(InputStream is, OutputStream os, long start, long end) throws IOException {
|
||||||
long skip = is.skip(start);
|
long skip = is.skip(start);
|
||||||
if (skip != start) {
|
if (skip != start) {
|
||||||
throw new ActionException(ResultCode.ERROR, "skip fail");
|
throw new TimiException(TimiCode.ERROR, "skip fail");
|
||||||
}
|
}
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
long remaining = end - start + 1;
|
long remaining = end - start + 1;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ package com.imyeyu.io;
|
|||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.CallbackArg;
|
import com.imyeyu.java.bean.CallbackArg;
|
||||||
import com.imyeyu.utils.Calc;
|
import com.imyeyu.utils.Calc;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -43,18 +41,9 @@ public class IOSpeedService {
|
|||||||
private static IOSpeedService service;
|
private static IOSpeedService service;
|
||||||
|
|
||||||
/** 加盐,用于在数据对齐的 IO 流中看起来像非对齐传输。此操作会使计算数据变得非真实,仅作为 UI 显示时可使用 */
|
/** 加盐,用于在数据对齐的 IO 流中看起来像非对齐传输。此操作会使计算数据变得非真实,仅作为 UI 显示时可使用 */
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private long salt;
|
private long salt;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private double totalBufferOld;
|
private double totalBufferOld, totalBuffer;
|
||||||
|
|
||||||
/** 总缓冲量 */
|
|
||||||
@Getter
|
|
||||||
private double totalBuffer;
|
|
||||||
|
|
||||||
/** true 为运行中 */
|
|
||||||
@Getter
|
|
||||||
private boolean isRunning;
|
private boolean isRunning;
|
||||||
|
|
||||||
private final Map<String, Item> items;
|
private final Map<String, Item> items;
|
||||||
@@ -147,6 +136,15 @@ public class IOSpeedService {
|
|||||||
return items.get(id);
|
return items.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取总缓冲量
|
||||||
|
*
|
||||||
|
* @return 缓冲数据量
|
||||||
|
*/
|
||||||
|
public double getTotalBuffer() {
|
||||||
|
return totalBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
/** 重置计算 */
|
/** 重置计算 */
|
||||||
public void reset() {
|
public void reset() {
|
||||||
totalBufferOld = totalBuffer = 0;
|
totalBufferOld = totalBuffer = 0;
|
||||||
@@ -174,6 +172,23 @@ public class IOSpeedService {
|
|||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否运行中
|
||||||
|
*
|
||||||
|
* @return true 为运行中
|
||||||
|
*/
|
||||||
|
public boolean isRunning() {
|
||||||
|
return isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSalt() {
|
||||||
|
return salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSalt(long salt) {
|
||||||
|
this.salt = salt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加全局字节量监听
|
* 添加全局字节量监听
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.imyeyu.io;
|
package com.imyeyu.io;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -18,10 +16,8 @@ import java.util.jar.JarFile;
|
|||||||
* @author 夜雨
|
* @author 夜雨
|
||||||
* @version 2021-12-01 17:39
|
* @version 2021-12-01 17:39
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
public class JarReader extends JarFile {
|
public class JarReader extends JarFile {
|
||||||
|
|
||||||
/** jar 所有文件的数据流映射列表,Map<路径, 数据流> */
|
|
||||||
private final Map<String, InputStream> files;
|
private final Map<String, InputStream> files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,4 +76,12 @@ public class JarReader extends JarFile {
|
|||||||
return IO.toBytes(getInputStream(path));
|
return IO.toBytes(getInputStream(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 jar 所有文件的数据流映射列表,Map<路径, 数据流>
|
||||||
|
*
|
||||||
|
* @return 数据流映射列表
|
||||||
|
*/
|
||||||
|
public Map<String, InputStream> getFiles() {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.imyeyu.io;
|
package com.imyeyu.io;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -12,7 +11,6 @@ import java.util.Stack;
|
|||||||
* @author 夜雨
|
* @author 夜雨
|
||||||
* @version 2024-06-30 16:26
|
* @version 2024-06-30 16:26
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
public class TreeFile extends File {
|
public class TreeFile extends File {
|
||||||
|
|
||||||
private List<TreeFile> children;
|
private List<TreeFile> children;
|
||||||
@@ -59,6 +57,10 @@ public class TreeFile extends File {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TreeFile> getChildren() {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user