Compare commits
14
Commits
v0.0.2
...
bdb82d4cfa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdb82d4cfa | ||
|
|
9190a9a0b2 | ||
|
|
a11ba5a907 | ||
|
|
ebd83595ec | ||
|
|
1fcd5b8300 | ||
|
|
2615862b23 | ||
|
|
33876140a7 | ||
|
|
47dbc3efaf | ||
|
|
319705c2fc | ||
|
|
1f67d8742a | ||
|
|
fb86228d03 | ||
|
|
cb50850eca | ||
|
|
5c5dabeb05 | ||
|
|
33177f5ded |
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.io</groupId>
|
<groupId>com.imyeyu.io</groupId>
|
||||||
<artifactId>timi-io</artifactId>
|
<artifactId>timi-io</artifactId>
|
||||||
<version>0.0.2</version>
|
<version>0.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -28,10 +28,42 @@
|
|||||||
<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>
|
||||||
@@ -60,7 +92,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.utils</groupId>
|
<groupId>com.imyeyu.utils</groupId>
|
||||||
<artifactId>timi-utils</artifactId>
|
<artifactId>timi-utils</artifactId>
|
||||||
<version>0.0.2</version>
|
<version>0.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
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.timi.TimiCode;
|
import com.imyeyu.java.bean.ResultCode;
|
||||||
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;
|
||||||
@@ -134,6 +135,20 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件对象,如果不存在则创建该文件
|
* 获取文件对象,如果不存在则创建该文件
|
||||||
*
|
*
|
||||||
@@ -218,7 +233,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 TimiException(TimiCode.RESULT_BAD, "rename file fail: from " + file.getAbsolutePath() + ", to " + resultFile.getAbsolutePath());
|
throw new ActionException(ResultCode.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) {
|
||||||
@@ -646,7 +661,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 TimiException(TimiCode.ERROR, "skip fail");
|
throw new ActionException(ResultCode.ERROR, "skip fail");
|
||||||
}
|
}
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
long remaining = end - start + 1;
|
long remaining = end - start + 1;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ 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;
|
||||||
@@ -41,9 +43,18 @@ 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, totalBuffer;
|
private double totalBufferOld;
|
||||||
|
|
||||||
|
/** 总缓冲量 */
|
||||||
|
@Getter
|
||||||
|
private double totalBuffer;
|
||||||
|
|
||||||
|
/** true 为运行中 */
|
||||||
|
@Getter
|
||||||
private boolean isRunning;
|
private boolean isRunning;
|
||||||
|
|
||||||
private final Map<String, Item> items;
|
private final Map<String, Item> items;
|
||||||
@@ -136,15 +147,6 @@ 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;
|
||||||
@@ -172,23 +174,6 @@ 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,5 +1,7 @@
|
|||||||
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;
|
||||||
@@ -16,8 +18,10 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,12 +80,4 @@ 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,6 +1,7 @@
|
|||||||
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;
|
||||||
@@ -11,6 +12,7 @@ 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;
|
||||||
@@ -57,10 +59,6 @@ public class TreeFile extends File {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TreeFile> getChildren() {
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user