channel.rmdir(pathName); } catch (SftpException e) { status = false;
@Override public boolean delete(Path path) throws IOException { ChannelSftp channel = null; try { channel = this.fsHelper.getSftpChannel(); if (getFileStatus(path).isDirectory()) { channel.rmdir(HadoopUtils.toUriPath(path)); } else { channel.rm(HadoopUtils.toUriPath(path)); } } catch (SftpException e) { throw new IOException(e); } finally { safeDisconnect(channel); } return true; }
channel.rmdir(dirPath); return true; } catch (SftpException e) {
channel.rmdir(dirPath); return true; } catch (SftpException e) {
@Override public boolean rmdir(String remoteDirectory) throws IOException { try { this.channel.rmdir(remoteDirectory); } catch (SftpException e) { throw new NestedIOException("failed to remove remote directory '" + remoteDirectory + "'.", e); } return true; }
@Override public boolean rmdir(String remoteDirectory) throws IOException { try { this.channel.rmdir(remoteDirectory); } catch (SftpException e) { throw new NestedIOException("failed to remove remote directory '" + remoteDirectory + "'.", e); } return true; }
public final boolean deleteFolder(String folder) throws JSchException, SftpException { ChannelSftp channel = (ChannelSftp) sesConnection.openChannel("sftp"); channel.connect(); channel.rmdir(folder); channel.disconnect(); return true; } }
public void rmdir(String path) throws SshException { try { channel.rmdir(path); } catch (SftpException e) { throw new net.sf.sshapi.sftp.SftpException(e.id, e.getLocalizedMessage(), e); } }
void delete(String path, boolean isDirectory) throws IOException { try { if (isDirectory) { channel.rmdir(path); } else { channel.rm(path); } } catch (SftpException e) { throw exceptionFactory.createDeleteException(path, e, isDirectory); } }
@Override public void rmdir(Path path) { try { this.channel.rmdir(PathHelper.toString(path)); } catch (SftpException e) { throw convertSftpException(e); } }
public void delete(ProtocolFile file) throws ProtocolException { try { if (file.isDir()) { sftpChannel.rmdir(file.getPath()); } else { sftpChannel.rm(file.getPath()); } } catch (Exception e) { throw new ProtocolException("Failed to download file '" + file + "' : " + e.getMessage(), e); } }
private synchronized boolean delete(String pathname, boolean directory) throws RemoteException { try { sftpLogger.info("DELE " + pathname); // NOI18N if (directory) { sftpClient.rmdir(pathname); } else { sftpClient.rm(pathname); } sftpLogger.info(NbBundle.getMessage(SftpClient.class, "LOG_FileDeleteOk")); return true; } catch (SftpException ex) { LOGGER.log(Level.FINE, "Error while deleting file " + pathname, ex); sftpLogger.error(ex.getLocalizedMessage()); return false; } }
@Override public boolean delete(Path path) throws IOException { ChannelSftp channel = null; try { channel = this.fsHelper.getSftpChannel(); if (getFileStatus(path).isDirectory()) { channel.rmdir(HadoopUtils.toUriPath(path)); } else { channel.rm(HadoopUtils.toUriPath(path)); } } catch (SftpException e) { throw new IOException(e); } finally { safeDisconnect(channel); } return true; }
@Test public void shouldDeleteRemoteDirectory() throws SftpException { when(mockChannel.ls("/some/directory/file.name/")).thenReturn(new Vector<LsEntry>()); FTPFile file = new FTPFile("file.name", 0, "/some/directory", 0, true); sftpConnection.deleteRemoteFile(file); verify(mockChannel).rmdir("/some/directory/file.name"); }
private static void recursiveDelete(ChannelSftp sftp, String path) throws SftpException, JSchException { Vector<?> entries = sftp.ls(path); for (Object object : entries) { LsEntry entry = (LsEntry) object; if (entry.getFilename().equals(".") || entry.getFilename().equals("..")) { continue; } if (entry.getAttrs().isDir()) { recursiveDelete(sftp, path + entry.getFilename() + "/"); } else { sftp.rm(path + entry.getFilename()); } } sftp.rmdir(path); }
@Test public void shouldCatchAndRethrowExceptionIfCaught() throws SftpException { expectedException.expect(FTPException.class); expectedException.expectMessage(equalTo("Unable to delete file on remote server")); when(mockChannel.ls("/some/directory/file.name/")).thenReturn(new Vector<LsEntry>()); FTPFile file = new FTPFile("file.name", 0, "/some/directory", 0, true); doThrow(new SftpException(0, "")).when(mockChannel).rmdir("/some/directory/file.name"); sftpConnection.deleteRemoteFile(file); }
/** * Deletes the file. */ @Override protected void doDelete() throws Exception { final ChannelSftp channel = getAbstractFileSystem().getChannel(); try { if (isFile()) { channel.rm(relPath); } else { channel.rmdir(relPath); } } finally { getAbstractFileSystem().putChannel(channel); } }
/** * Deletes the file. */ @Override protected void doDelete() throws Exception { final ChannelSftp channel = getAbstractFileSystem().getChannel(); try { if (isFile()) { channel.rm(relPath); } else { channel.rmdir(relPath); } } finally { getAbstractFileSystem().putChannel(channel); } }
/** * Deletes the file. */ @Override protected void doDelete() throws Exception { final ChannelSftp channel = getAbstractFileSystem().getChannel(); try { if (isFile()) { channel.rm(relPath); } else { channel.rmdir(relPath); } } finally { getAbstractFileSystem().putChannel(channel); } }
private static void doRemove(ChannelSftp sftp, String dir) throws SftpException{ // 如果参数不是目录则抛出异常 if (!sftp.stat(dir).isDir()) { throw new RdfFileException("target is not dir, target=" + dir, RdfErrorEnum.UNSUPPORTED_OPERATION); } Vector<LsEntry> currentLsEntryVec = sftp.ls(dir); for(LsEntry lsEntry : currentLsEntryVec){ SftpFileEntry sftpFileEntry = SftpFileEntry .buildFileEntry(RdfFileUtil.combinePath(dir, lsEntry.getFilename()), lsEntry); if(sftpFileEntry.isDir()){ if((!sftpFileEntry.isCurrentDir() && !sftpFileEntry.isPrevDir())){ doRemove(sftp, sftpFileEntry.getFullFileName()); } }else{ sftp.rm(sftpFileEntry.getFullFileName()); } } sftp.rmdir(dir); }