mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +02:00
Bug 140323 - FTP move, delete, and rename do not work.
This commit is contained in:
parent
e2b4dfdcec
commit
bdfd3308eb
1 changed files with 68 additions and 35 deletions
|
@ -12,6 +12,8 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Michael Berger (IBM) - Fixing 140408 - FTP upload does not work
|
* Michael Berger (IBM) - Fixing 140408 - FTP upload does not work
|
||||||
|
* Javier Montalvo Orus (Symbian) - Fixing 140323 - provided implementation for
|
||||||
|
* delete, move and rename.
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.services.files.ftp;
|
package org.eclipse.rse.services.files.ftp;
|
||||||
|
@ -22,6 +24,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -49,8 +52,6 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
private String _userHome;
|
private String _userHome;
|
||||||
private IFTPDirectoryListingParser _ftpPropertiesUtil;
|
private IFTPDirectoryListingParser _ftpPropertiesUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private transient String _hostname;
|
private transient String _hostname;
|
||||||
private transient String _userId;
|
private transient String _userId;
|
||||||
private transient String _password;
|
private transient String _password;
|
||||||
|
@ -155,9 +156,6 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
return getFTPClient().serverIsOpen();
|
return getFTPClient().serverIsOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected IHostFile[] internalFetch(IProgressMonitor monitor, String parentPath, String fileFilter, int fileType)
|
protected IHostFile[] internalFetch(IProgressMonitor monitor, String parentPath, String fileFilter, int fileType)
|
||||||
{
|
{
|
||||||
if (fileFilter == null)
|
if (fileFilter == null)
|
||||||
|
@ -323,20 +321,64 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
return new IHostFile[] { root };
|
return new IHostFile[] { root };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
// TODO
|
* @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String)
|
||||||
/********************************************************
|
*/
|
||||||
*
|
public boolean delete(IProgressMonitor monitor, String remoteParent, String fileName) {
|
||||||
* The following APIs need to be implemented
|
boolean hasSucceeded = false;
|
||||||
*
|
try {
|
||||||
********************************************************/
|
getFTPClient().cd(remoteParent);
|
||||||
|
int returnedValue = getFTPClient().sendCommand("DELE " + fileName);
|
||||||
public IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
|
hasSucceeded = (returnedValue > 0);
|
||||||
{
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated method stub
|
// Changing folder raised an exception
|
||||||
return null;
|
hasSucceeded = false;
|
||||||
|
}
|
||||||
|
return hasSucceeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName) {
|
||||||
|
boolean hasSucceeded = false;
|
||||||
|
int returnedValue = getFTPClient().sendCommand("RNFR " + remoteParent + getSeparator() + oldName);
|
||||||
|
if (returnedValue > 0) {
|
||||||
|
returnedValue = getFTPClient().sendCommand("RNTO " + remoteParent + getSeparator() + newName);
|
||||||
|
hasSucceeded = (returnedValue > 0);
|
||||||
|
}
|
||||||
|
return hasSucceeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.services.files.IFileService#rename(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, org.eclipse.rse.services.files.IHostFile)
|
||||||
|
*/
|
||||||
|
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile) {
|
||||||
|
boolean hasSucceeded = false;
|
||||||
|
int returnedValue = getFTPClient().sendCommand("RNFR " + remoteParent + getSeparator() + oldName);
|
||||||
|
if (returnedValue > 0) {
|
||||||
|
returnedValue = getFTPClient().sendCommand("RNTO " + remoteParent + getSeparator() + newName);
|
||||||
|
hasSucceeded = (returnedValue > 0);
|
||||||
|
}
|
||||||
|
return hasSucceeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.services.files.IFileService#move(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) {
|
||||||
|
boolean hasSucceeded = false;
|
||||||
|
int returnedValue = getFTPClient().sendCommand("RNFR " + srcParent + getSeparator() + srcName);
|
||||||
|
if (returnedValue > 0) {
|
||||||
|
returnedValue = getFTPClient().sendCommand("RNTO " + tgtParent + getSeparator() + tgtName);
|
||||||
|
hasSucceeded = (returnedValue > 0);
|
||||||
|
}
|
||||||
|
return hasSucceeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.services.files.IFileService#createFolder(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
public IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName)
|
public IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -352,24 +394,17 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
return getFile(monitor, remoteParent, folderName);
|
return getFile(monitor, remoteParent, folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delete(IProgressMonitor monitor, String remoteParent, String fileName)
|
// TODO
|
||||||
{
|
/********************************************************
|
||||||
return false;
|
*
|
||||||
}
|
* The following APIs need to be implemented
|
||||||
|
*
|
||||||
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName)
|
********************************************************/
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile)
|
public IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
|
||||||
{
|
{
|
||||||
return false;
|
// TODO Auto-generated method stub
|
||||||
}
|
return null;
|
||||||
|
|
||||||
public boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
|
public boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
|
||||||
|
@ -399,7 +434,5 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue