1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-20 06:35:50 +02:00

[161238] [ftp] connections to VMS servers are not usable -- improved file listing

This commit is contained in:
Javier Montalvo Orus 2006-11-20 12:50:12 +00:00
parent 56d704fa4d
commit 58e0741aaa
2 changed files with 42 additions and 36 deletions

View file

@ -61,13 +61,32 @@ public class FTPHostFile implements IHostFile
{ {
_systemName = systemName; _systemName = systemName;
_parentPath = parentPath; _parentPath = parentPath;
if(systemName.equals(FTPClientConfig.SYST_VMS))
{
_name = ftpFile.getName(); _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(); _isDirectory = ftpFile.isDirectory();
_lastModified = ftpFile.getTimestamp().getTimeInMillis(); _lastModified = ftpFile.getTimestamp().getTimeInMillis();
_size = ftpFile.getSize(); _size = ftpFile.getSize();
_isArchive = internalIsArchive(); _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); _canRead = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION);
_canWrite = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION); _canWrite = ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION);
@ -111,19 +130,7 @@ public class FTPHostFile implements IHostFile
public String getAbsolutePath() 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(); return getName();
} else { } else {
StringBuffer path = new StringBuffer(getParentPath()); StringBuffer path = new StringBuffer(getParentPath());
@ -134,7 +141,7 @@ public class FTPHostFile implements IHostFile
path.append(getName()); path.append(getName());
return path.toString(); return path.toString();
} }
}
} }
public long getModifiedDate() public long getModifiedDate()
@ -155,7 +162,7 @@ public class FTPHostFile implements IHostFile
} }
public boolean isRoot() { public boolean isRoot() {
return _parentPath==null; return _isRoot;
} }

View file

@ -221,6 +221,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
_ftpClient.configure(ftpClientConfig); _ftpClient.configure(ftpClientConfig);
_userHome = _ftpClient.printWorkingDirectory(); _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() public void disconnect()
@ -361,21 +370,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
{ {
_ftpClient = getFTPClient(); _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)) if(!_ftpClient.changeWorkingDirectory(parentPath))
{ {
return null; return null;
} }
if(!listFiles(monitor)) if(!listFiles(monitor))
{ {
return null; return null;
@ -383,10 +382,10 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
for(int i=0; i<_ftpFiles.length; i++) 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()) if(filematcher.matches(f.getName()) || f.isDirectory())
{ {
results.add(new FTPHostFile(parentPath,_ftpFiles[i],_systemName)); results.add(f);
} }
} }
} }