From 58e0741aaa35992825e42caa975791e713c3b744 Mon Sep 17 00:00:00 2001 From: Javier Montalvo Orus Date: Mon, 20 Nov 2006 12:50:12 +0000 Subject: [PATCH] [161238] [ftp] connections to VMS servers are not usable -- improved file listing --- .../rse/services/files/ftp/FTPHostFile.java | 55 +++++++++++-------- .../rse/services/files/ftp/FTPService.java | 23 ++++---- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java index bcba8ef8e17..9fb96b13d75 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPHostFile.java @@ -61,13 +61,32 @@ public class FTPHostFile implements IHostFile { _systemName = systemName; _parentPath = parentPath; - _name = ftpFile.getName(); + + if(systemName.equals(FTPClientConfig.SYST_VMS)) + { + _name = ftpFile.getName(); + if(_name.indexOf(".DIR")!=-1) //$NON-NLS-1$ + { + _name = _name.substring(0,_name.indexOf(".DIR")); //$NON-NLS-1$ + } + else + { + _name = _name.substring(0,_name.indexOf(";")); //$NON-NLS-1$ + } + } + else + { + _name = ftpFile.getName(); + } + _isDirectory = ftpFile.isDirectory(); _lastModified = ftpFile.getTimestamp().getTimeInMillis(); _size = ftpFile.getSize(); _isArchive = internalIsArchive(); - if(!systemName.equals(FTPClientConfig.SYST_NT)) //"WINDOWS" + //In Windows r/w is not listed + //In VMS it is not implemented in the Jakarta parser + if(!systemName.equals(FTPClientConfig.SYST_NT) && !systemName.equals(FTPClientConfig.SYST_VMS)) { _canRead = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION); _canWrite = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION); @@ -111,30 +130,18 @@ public class FTPHostFile implements IHostFile public String getAbsolutePath() { - if(_systemName==null) + if (isRoot() || _parentPath==null) { return getName(); - - if(_systemName.equals(FTPClientConfig.SYST_VMS)) //"VMS" - { - if (isRoot()) - return getName(); - else - return getParentPath()+getName(); - } - else - { - if (isRoot()) { - return getName(); - } else { - StringBuffer path = new StringBuffer(getParentPath()); - if (!_parentPath.endsWith("/") && !_parentPath.endsWith("\\"))//$NON-NLS-1$ //$NON-NLS-2$ - { - path.append('/'); - } - path.append(getName()); - return path.toString(); + } else { + StringBuffer path = new StringBuffer(getParentPath()); + if (!_parentPath.endsWith("/") && !_parentPath.endsWith("\\"))//$NON-NLS-1$ //$NON-NLS-2$ + { + path.append('/'); } + path.append(getName()); + return path.toString(); } + } public long getModifiedDate() @@ -155,7 +162,7 @@ public class FTPHostFile implements IHostFile } public boolean isRoot() { - return _parentPath==null; + return _isRoot; } diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java index 93a0ccc9354..f104c0220b4 100644 --- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java +++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/services/files/ftp/FTPService.java @@ -221,6 +221,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT _ftpClient.configure(ftpClientConfig); _userHome = _ftpClient.printWorkingDirectory(); + + //For VMS, normalize the home location + if(_systemName.equals(FTPClientConfig.SYST_VMS)) + { + String name = getName(); + _userHome = _userHome.replaceAll(":\\[", "/"); //$NON-NLS-1$ //$NON-NLS-2$ + _userHome = "/"+_userHome.substring(0,_userHome.lastIndexOf(']')); //$NON-NLS-1$ + } + } public void disconnect() @@ -361,21 +370,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT { _ftpClient = getFTPClient(); - // VMS path requires some preprocessing - if(_systemName.equals(FTPClientConfig.SYST_VMS) && !parentPath.endsWith("]")) //"VMS" //$NON-NLS-1$ - { - parentPath = parentPath.substring(0,parentPath.indexOf(".DIR")); //$NON-NLS-1$ - parentPath = parentPath.replace(']', '.'); - parentPath+="]"; //$NON-NLS-1$ - } - if(!_ftpClient.changeWorkingDirectory(parentPath)) { return null; } - - if(!listFiles(monitor)) { return null; @@ -383,10 +382,10 @@ public class FTPService extends AbstractFileService implements IFileService, IFT for(int i=0; i<_ftpFiles.length; i++) { - FTPFile f = _ftpFiles[i]; + FTPHostFile f = new FTPHostFile(parentPath,_ftpFiles[i],_systemName); if(filematcher.matches(f.getName()) || f.isDirectory()) { - results.add(new FTPHostFile(parentPath,_ftpFiles[i],_systemName)); + results.add(f); } } }