@Override /** * @return void * @param String destination */ public void changeToDirectory(String directory) throws IOException { ftpsClient.changeWorkingDirectory(directory); }
@Override public void changeWorkingDirectory(String pathname) throws IOException { client.changeWorkingDirectory(pathname); }
/** * Creates directories on FTP server * * @param directory directory to create * @return SimpleFtpClientResult.CREATED on succes SimpleFtpClientResult.ERROR on error * @throws IOException on error */ public boolean createDirectories(final String directory) throws IOException { String[] iterable = directory.split("/"); for (String dir : iterable) { boolean dirExists = client.changeWorkingDirectory(dir); if (!dirExists) { // try to create directory: client.makeDirectory(dir); dirExists = client.changeWorkingDirectory(dir); } if (!dirExists) { LogUtils.LOGD(TAG, "failed to change FTP directory (forms), not doing anything"); return false; } } return true; }
public void rename(String currentPath, String newPath) throws ClientCommandRenameException { logger.debug("rename called with currentPath [" + currentPath + "], newPath [" + newPath + "]"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ try { String dirBefore = this.ftpClient.printWorkingDirectory(); logger.debug("Working directory before rename = [" + dirBefore + "]"); //$NON-NLS-1$ //$NON-NLS-2$ logger.debug("Current Path = [" + currentPath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ logger.debug("New Path = [" + newPath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ if(!this.ftpClient.rename(currentPath, newPath)) { throw new ClientCommandRenameException("Failed to rename [" + currentPath + "] to [" + newPath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } logger.debug("Successfully renamed [" + currentPath + "] to [" //$NON-NLS-1$ //$NON-NLS-2$ + newPath + "]"); //$NON-NLS-1$ String dirAfter = this.ftpClient.printWorkingDirectory(); logger.debug("Working directory after rename = [" + dirAfter + "]"); //$NON-NLS-1$ //$NON-NLS-2$ if(!dirBefore.equals(dirAfter)) { this.ftpClient.changeWorkingDirectory(dirBefore); logger.debug("Returning to previous working = [" + dirBefore + "]"); //$NON-NLS-1$//$NON-NLS-2$ } } catch (IOException e) { throw new ClientCommandRenameException("Failed to rename [" + currentPath + "] to [" + newPath + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
public void cd(String targetPath) throws ClientCommandCdException { // This code is not quite ideal as printWorkingDirectory() could fail // but the net result is that the developer will be informed of the // fault regardless String currentDirectory = null; try { currentDirectory = this.ftpClient.printWorkingDirectory(); if(!this.ftpClient.changeWorkingDirectory(targetPath)) { throw new ClientCommandCdException("Failed to call directory [" + targetPath //$NON-NLS-1$ + "] from [" + currentDirectory + "]"); //$NON-NLS-1$//$NON-NLS-2$ } logger.debug("CD from [" + currentDirectory + "] to [" + this.ftpClient.printWorkingDirectory() + "]."); } catch (IOException e) { throw new ClientCommandCdException("Failed to call directory [" + targetPath //$NON-NLS-1$ + "] from [" + currentDirectory + "]", e); //$NON-NLS-1$//$NON-NLS-2$ } }
if(!this.ftpClient.changeWorkingDirectory(path)) if (!this.ftpClient.changeWorkingDirectory(dir)) if(!this.ftpClient.changeWorkingDirectory(startDir))
if(!this.ftpClient.changeWorkingDirectory(pathElement)) if(!this.ftpClient.changeWorkingDirectory(pathElement)) if(!this.ftpClient.changeWorkingDirectory(cwd))
ftpClient.execPBSZ(0); ftpClient.execPROT("P"); ftpClient.changeWorkingDirectory("/");
ftpsClient.setControlKeepAliveTimeout(300); if (getWorkingDirectory() != null) { ftpsClient.changeWorkingDirectory(getWorkingDirectory());