mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
ftp.exist分支优化
This commit is contained in:
parent
feb62498fd
commit
f279b4a9ac
@ -100,13 +100,15 @@ public abstract class AbstractFtp implements Closeable {
|
|||||||
// 目录验证
|
// 目录验证
|
||||||
if (isDir(path)) {
|
if (isDir(path)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
if (CharUtil.isFileSeparator(path.charAt(path.length() - 1))) {
|
if (CharUtil.isFileSeparator(path.charAt(path.length() - 1))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final String fileName = FileUtil.getName(path);
|
||||||
|
if (".".equals(fileName) || "..".equals(fileName)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
// 文件验证
|
// 文件验证
|
||||||
final String fileName = FileUtil.getName(path);
|
|
||||||
final String dir = StrUtil.removeSuffix(path, fileName);
|
final String dir = StrUtil.removeSuffix(path, fileName);
|
||||||
final List<String> names;
|
final List<String> names;
|
||||||
try {
|
try {
|
||||||
|
@ -122,14 +122,19 @@ public class FtpTest {
|
|||||||
@Ignore
|
@Ignore
|
||||||
public void existFtpTest() throws Exception {
|
public void existFtpTest() throws Exception {
|
||||||
try (Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
try (Ftp ftp = new Ftp("127.0.0.1", 21)) {
|
||||||
Console.log(ftp.exist("/test/"));
|
Console.log(ftp.exist("/test"));
|
||||||
Console.log(ftp.exist("/test/"));
|
Console.log(ftp.exist("/test/"));
|
||||||
Console.log(ftp.exist("/test//////"));
|
Console.log(ftp.exist("/test//////"));
|
||||||
|
Console.log(ftp.exist("/test/.."));
|
||||||
|
Console.log(ftp.exist("/test/."));
|
||||||
Console.log(ftp.exist("/file1"));
|
Console.log(ftp.exist("/file1"));
|
||||||
Console.log(ftp.exist("/file1/"));
|
Console.log(ftp.exist("/file1/"));
|
||||||
Console.log(ftp.exist("///////////"));
|
Console.log(ftp.exist("///////////"));
|
||||||
Console.log(ftp.exist("./"));
|
Console.log(ftp.exist("./"));
|
||||||
Console.log(ftp.exist("./file1"));
|
Console.log(ftp.exist("./file1"));
|
||||||
|
Console.log(ftp.exist("."));
|
||||||
|
Console.log(ftp.exist("./2/3/4/.."));
|
||||||
|
Console.log(ftp.ls("./2/3/4/.."));
|
||||||
Console.log(ftp.pwd());
|
Console.log(ftp.pwd());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user