Compare commits
8
Commits
v0.0.5
..
bdb82d4cfa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdb82d4cfa | ||
|
|
9190a9a0b2 | ||
|
|
a11ba5a907 | ||
|
|
ebd83595ec | ||
|
|
1fcd5b8300 | ||
|
|
2615862b23 | ||
|
|
33876140a7 | ||
|
|
47dbc3efaf |
@@ -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.5</version>
|
<version>0.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -92,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.5</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;
|
||||||
|
|||||||
Reference in New Issue
Block a user