1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

[204669] Fix ftp path concatenation on systems using backslash separator

This commit is contained in:
Martin Oberhuber 2007-09-26 13:24:53 +00:00
parent 9cbfce5440
commit be038e0311
5 changed files with 60 additions and 25 deletions

View file

@ -13,6 +13,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Rupen Mardirossian (IBM) - [187530] Commented out line 192, in order to stop logging of SystemMessageException
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
********************************************************************************/
package org.eclipse.rse.internal.files.ui.wizards;
@ -174,7 +175,7 @@ public class SystemNewFileWizard
IRemoteFile newFile = null;
IProgressMonitor monitor = new NullProgressMonitor();
try {
IRemoteFile newFilePath = rfss.getRemoteFileObject(absName, monitor);
IRemoteFile newFilePath = rfss.getRemoteFileObject(parentFolder, name, monitor);
newFile = rfss.createFile(newFilePath, monitor);
} catch (RemoteFileIOException exc ) {
SystemBasePlugin.logDebugMessage(CLASSNAME+ ":", " Creating remote file "+ absName + " failed with RemoteFileIOException " ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

View file

@ -13,12 +13,12 @@
* Contributors:
* Michael Berger (IBM) - Fixing 140408 - FTP upload does not work
* Javier Montalvo Orús (Symbian) - Migrate to jakarta commons net FTP client
* Javier Montalvo Orus (Symbian) - Fixing 161211 - Cannot expand /pub folder as
* anonymous on ftp.wacom.com
* Javier Montalvo Orus (Symbian) - Fixing 161211 - Cannot expand /pub folder as anonymous on ftp.wacom.com
* Javier Montalvo Orus (Symbian) - Fixing 161238 - [ftp] connections to VMS servers are not usable
* Javier Montalvo Orus (Symbian) - Fixing 176216 - [api] FTP sould provide API to allow clients register their own FTPListingParser
* Javier Montalvo Orus (Symbian) - [197758] Unix symbolic links are not classified as file vs. folder
* Javier Montalvo Orus (Symbian) - [198272] FTP should return classification for symbolic links so they show a link overlay
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
********************************************************************************/
package org.eclipse.rse.internal.services.files.ftp;
@ -27,6 +27,7 @@ package org.eclipse.rse.internal.services.files.ftp;
import java.io.File;
import org.apache.commons.net.ftp.FTPFile;
import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.files.IHostFile;
@ -123,15 +124,19 @@ public class FTPHostFile implements IHostFile
if (isRoot() || _parentPath==null) {
return getName();
} else {
StringBuffer path = new StringBuffer(getParentPath());
if (!_parentPath.endsWith("/") && !_parentPath.endsWith("\\"))//$NON-NLS-1$ //$NON-NLS-2$
String parentPath = getParentPath();
StringBuffer path = new StringBuffer(parentPath);
if (!parentPath.endsWith("/") && !parentPath.endsWith("\\"))//$NON-NLS-1$ //$NON-NLS-2$
{
path.append('/');
//TODO IFileService should have a method for this
String sep = PathUtility.getSeparator(parentPath);
if (!parentPath.endsWith(sep)) {
path.append(sep);
}
}
path.append(getName());
return path.toString();
}
}
public long getModifiedDate()

View file

@ -59,6 +59,7 @@
* Martin Oberhuber (Wind River) - [199548] Avoid touching files on setReadOnly() if unnecessary
* Javier Montalvo Orus (Symbian) - [199243] Renaming a file in an FTP-based EFS folder hangs all of Eclipse
* Martin Oberhuber (Wind River) - [203306] Fix Deadlock comparing two files on FTP
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
********************************************************************************/
package org.eclipse.rse.internal.services.files.ftp;
@ -93,6 +94,7 @@ import org.eclipse.rse.services.Mutex;
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
import org.eclipse.rse.services.clientserver.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.services.files.AbstractFileService;
import org.eclipse.rse.services.files.IFileService;
@ -135,7 +137,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
private static long FTP_STATCACHE_TIMEOUT = 200; //msec
private class FTPBufferedInputStream extends BufferedInputStream {
private static class FTPBufferedInputStream extends BufferedInputStream {
private FTPClient client;
@ -379,6 +381,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
}
catch (IOException e)
{
}
finally {
_ftpClient = null;
}
@ -661,15 +665,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
private char getSeparator()
{
char separator = '/';
if(_userHome.indexOf('\\')!=-1 && _userHome.indexOf('/')==-1)
{
separator = '\\';
}
return separator;
return PathUtility.getSeparator(_userHome).charAt(0);
}
/*

View file

@ -19,7 +19,8 @@
* Javier Montalvo Orus (Symbian) - Fixing 176216 - [api] FTP sould provide API to allow clients register their own FTPListingParser
* Javier Montalvo Orus (Symbian) - [187531] Improve exception thrown when Login Failed on FTP
* David Dykstal (IBM) - added RESID_FTP_SETTINGS_LABEL
* David McKnight (IBM) - [196632] [ftp] Passive mode setting does not work
* David McKnight (IBM) - [196632] [ftp] Passive mode setting does not work
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
********************************************************************************/
package org.eclipse.rse.internal.subsystems.files.ftp.connectorservice;
@ -38,6 +39,7 @@ import org.eclipse.rse.internal.services.files.ftp.FTPService;
import org.eclipse.rse.internal.subsystems.files.ftp.FTPSubsystemResources;
import org.eclipse.rse.internal.subsystems.files.ftp.parser.FTPClientConfigFactory;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.services.files.IHostFile;
import org.eclipse.rse.services.files.RemoteFileException;
import org.eclipse.rse.ui.subsystems.StandardConnectorService;
import org.eclipse.ui.console.ConsolePlugin;
@ -49,7 +51,7 @@ import org.eclipse.ui.console.MessageConsole;
public class FTPConnectorService extends StandardConnectorService
{
protected FTPService _ftpService;
public FTPConnectorService(IHost host, int port)
{
super(FTPSubsystemResources.RESID_FTP_CONNECTORSERVICE_NAME,FTPSubsystemResources.RESID_FTP_CONNECTORSERVICE_DESCRIPTION, host, port);
@ -109,7 +111,21 @@ public class FTPConnectorService extends StandardConnectorService
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.subsystems.AbstractConnectorService#getHomeDirectory()
*/
public String getHomeDirectory() {
if (_ftpService!=null) {
IHostFile f = _ftpService.getUserHome();
if (f!=null) {
return f.getAbsolutePath();
}
}
//fallback while not yet connected
return super.getHomeDirectory();
}
private OutputStream getLoggingStream(String hostName,int portNumber)
{
MessageConsole messageConsole=null;

View file

@ -13,12 +13,14 @@
*
* Contributors:
* Javier Montalvo Orus (Symbian) - [198272] FTP should return classification for symbolic links so they show a link overlay
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.files.ftp.model;
import org.eclipse.rse.internal.services.files.ftp.FTPHostFile;
import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.AbstractRemoteFile;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
@ -51,11 +53,26 @@ public class FTPRemoteFile extends AbstractRemoteFile
return _ftpHostFile.getClassification();
}
/* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile#getSeparator()
*/
public String getSeparator() {
String absPath = getAbsolutePath();
if (absPath!=null && absPath.length()>1) {
return PathUtility.getSeparator(absPath);
}
String home = getParentRemoteFileSubSystem().getConnectorService().getHomeDirectory();
if (home!=null && home.length()>1) {
return PathUtility.getSeparator(home);
}
return PathUtility.getSeparator(absPath);
}
/* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile#getSeparatorChar()
*/
public char getSeparatorChar() {
return getSeparator().charAt(0);
}
}