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;
_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;
}

View file

@ -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);
}
}
}