mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add rename
This commit is contained in:
@@ -403,6 +403,15 @@ public class CommonsFtp extends AbstractFtp {
|
||||
return ftpFiles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rename(String oldPath, String newPath) {
|
||||
try {
|
||||
return this.client.rename(oldPath, newPath);
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mkdir(final String dir) throws IORuntimeException {
|
||||
try {
|
||||
|
@@ -127,6 +127,15 @@ public interface Ftp extends Closeable {
|
||||
*/
|
||||
List<String> ls(String path);
|
||||
|
||||
/**
|
||||
* 重命名文件
|
||||
*
|
||||
* @param oldPath 旧文件名(或路径)
|
||||
* @param newPath 新文件名(或路径)
|
||||
* @return 是否重命名成功
|
||||
*/
|
||||
boolean rename(String oldPath, String newPath);
|
||||
|
||||
/**
|
||||
* 删除指定目录下的指定文件
|
||||
*
|
||||
|
@@ -328,6 +328,16 @@ public class JschSftp extends AbstractFtp {
|
||||
return entryList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rename(String oldPath, String newPath) {
|
||||
try {
|
||||
getClient().rename(oldPath, newPath);
|
||||
} catch (final SftpException e) {
|
||||
throw new SshException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mkdir(final String dir) {
|
||||
if (isDir(dir)) {
|
||||
|
@@ -188,6 +188,16 @@ public class SshjSftp extends AbstractFtp {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rename(String oldPath, String newPath) {
|
||||
try {
|
||||
sftp.rename(oldPath, newPath);
|
||||
return containsFile(newPath);
|
||||
} catch (final IOException e) {
|
||||
throw new FtpException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delFile(final String path) {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user