修复isDir判断改变pwd的问题

This commit is contained in:
yebukong 2022-08-31 12:54:35 +08:00
parent b1642d4625
commit 4852d67bed
2 changed files with 16 additions and 1 deletions

View File

@ -73,7 +73,12 @@ public abstract class AbstractFtp implements Closeable {
* @since 5.7.5 * @since 5.7.5
*/ */
public boolean isDir(String dir) { public boolean isDir(String dir) {
final String workDir = pwd();
try {
return cd(dir); return cd(dir);
} finally {
cd(workDir);
}
} }
/** /**

View File

@ -90,4 +90,14 @@ public class FtpTest {
FileUtil.file("d:/test/download/" + name)); FileUtil.file("d:/test/download/" + name));
} }
} }
@Test
@Ignore
public void isDirTest() throws Exception {
try (Ftp ftp = new Ftp("127.0.0.1", 21)) {
Console.log(ftp.pwd());
ftp.isDir("/test");
Console.log(ftp.pwd());
}
}
} }