mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[235360][ftp][ssh][local] Return proper "Root" IHostFile
This commit is contained in:
parent
aa2297c58b
commit
06bb64c597
6 changed files with 142 additions and 88 deletions
|
@ -22,6 +22,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
|
* Martin Oberhuber (Wind River) - [204669] Fix ftp path concatenation on systems using backslash separator
|
||||||
* Javier Montalvo Orus (Symbian) - [198692] FTP should mark files starting with "." as hidden
|
* Javier Montalvo Orus (Symbian) - [198692] FTP should mark files starting with "." as hidden
|
||||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.files.ftp;
|
package org.eclipse.rse.internal.services.files.ftp;
|
||||||
|
@ -58,6 +59,9 @@ public class FTPHostFile implements IHostFile, IHostFilePermissionsContainer
|
||||||
{
|
{
|
||||||
_parentPath = parentPath;
|
_parentPath = parentPath;
|
||||||
_name = name;
|
_name = name;
|
||||||
|
if (name == null || name.length() == 0) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
_isDirectory = isDirectory;
|
_isDirectory = isDirectory;
|
||||||
_lastModified = lastModified;
|
_lastModified = lastModified;
|
||||||
_size = size;
|
_size = size;
|
||||||
|
@ -180,16 +184,27 @@ public class FTPHostFile implements IHostFile, IHostFilePermissionsContainer
|
||||||
public void renameTo(String newAbsolutePath)
|
public void renameTo(String newAbsolutePath)
|
||||||
{
|
{
|
||||||
int i = newAbsolutePath.lastIndexOf("/"); //$NON-NLS-1$
|
int i = newAbsolutePath.lastIndexOf("/"); //$NON-NLS-1$
|
||||||
if (i == -1)
|
if (i == -1) {
|
||||||
{
|
//Rename inside the same parent folder.
|
||||||
|
//FIXME is this really what was desired here? Or would we rename Roots?
|
||||||
|
//Renaming Roots isn't possible, I'd think.
|
||||||
_name = newAbsolutePath;
|
_name = newAbsolutePath;
|
||||||
}
|
}
|
||||||
else
|
else if (i == 0) {
|
||||||
{
|
// Renaming a root folder
|
||||||
|
if (newAbsolutePath.length()==1) {
|
||||||
|
//rename to root "/" -- should this work?
|
||||||
|
_parentPath = null;
|
||||||
|
_isRoot = true;
|
||||||
|
_name = newAbsolutePath;
|
||||||
|
} else {
|
||||||
|
_parentPath = "/"; //$NON-NLS-1$
|
||||||
|
_name = newAbsolutePath.substring(i + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
_parentPath = newAbsolutePath.substring(0, i);
|
_parentPath = newAbsolutePath.substring(0, i);
|
||||||
_name = newAbsolutePath.substring(i+1);
|
_name = newAbsolutePath.substring(i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isArchive = internalIsArchive();
|
_isArchive = internalIsArchive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [218040] FTP should support permission modification
|
* Martin Oberhuber (Wind River) - [218040] FTP should support permission modification
|
||||||
* Martin Oberhuber (Wind River) - [234045] FTP Permission Error Handling
|
* Martin Oberhuber (Wind River) - [234045] FTP Permission Error Handling
|
||||||
* Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
|
* Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.files.ftp;
|
package org.eclipse.rse.internal.services.files.ftp;
|
||||||
|
@ -321,6 +322,8 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
* @throws SystemMessageException if information is lost
|
* @throws SystemMessageException if information is lost
|
||||||
*/
|
*/
|
||||||
protected String checkEncoding(String s) throws SystemMessageException {
|
protected String checkEncoding(String s) throws SystemMessageException {
|
||||||
|
if (s == null || s.length() == 0)
|
||||||
|
return s;
|
||||||
String encoding = _controlEncoding!=null ? _controlEncoding : getFTPClient().getControlEncoding();
|
String encoding = _controlEncoding!=null ? _controlEncoding : getFTPClient().getControlEncoding();
|
||||||
try {
|
try {
|
||||||
byte[] bytes = s.getBytes(encoding);
|
byte[] bytes = s.getBytes(encoding);
|
||||||
|
@ -574,6 +577,12 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
*/
|
*/
|
||||||
protected FTPHostFile getFileInternal(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
protected FTPHostFile getFileInternal(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
|
boolean isRoot = (remoteParent == null || remoteParent.length() == 0);
|
||||||
|
if (isRoot) {
|
||||||
|
// FTP doesn't really support getting properties of Roots yet. For
|
||||||
|
// now, return the root and claim it's existing.
|
||||||
|
return new FTPHostFile(remoteParent, fileName, true, true, 0, 0, true);
|
||||||
|
}
|
||||||
remoteParent = checkEncoding(remoteParent);
|
remoteParent = checkEncoding(remoteParent);
|
||||||
fileName = checkEncoding(fileName);
|
fileName = checkEncoding(fileName);
|
||||||
if (monitor!=null){
|
if (monitor!=null){
|
||||||
|
@ -999,7 +1008,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
||||||
//Returning null in this case is safest, see also SftpFileService.
|
//Returning null in this case is safest, see also SftpFileService.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new FTPHostFile("",_userHome,true,true,0,0,true); //$NON-NLS-1$
|
return new FTPHostFile(null, _userHome, true, true, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
* David McKnight (IBM) - [231211] Local xml file not opened when workspace encoding is different from local system encoding
|
* David McKnight (IBM) - [231211] Local xml file not opened when workspace encoding is different from local system encoding
|
||||||
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
|
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
|
||||||
* Martin Oberhuber (Wind River) - [233993] Improve EFS error reporting
|
* Martin Oberhuber (Wind River) - [233993] Improve EFS error reporting
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.local.files;
|
package org.eclipse.rse.internal.services.local.files;
|
||||||
|
@ -782,7 +783,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
|
||||||
{
|
{
|
||||||
String userHome =System.getProperty("user.home"); //$NON-NLS-1$
|
String userHome =System.getProperty("user.home"); //$NON-NLS-1$
|
||||||
File userHomeFile = new File(userHome);
|
File userHomeFile = new File(userHome);
|
||||||
return new LocalHostFile(userHomeFile);
|
return new LocalHostFile(userHomeFile, (userHomeFile.getParent() == null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -831,7 +832,8 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
|
||||||
|
|
||||||
boolean isVirtualParent = false;
|
boolean isVirtualParent = false;
|
||||||
boolean isArchiveParent = false;
|
boolean isArchiveParent = false;
|
||||||
if (remoteParent != null) {
|
boolean isRoot = (remoteParent == null || remoteParent.length() == 0);
|
||||||
|
if (!isRoot) {
|
||||||
File remoteParentFile = new File(remoteParent);
|
File remoteParentFile = new File(remoteParent);
|
||||||
if (!remoteParentFile.exists()) {
|
if (!remoteParentFile.exists()) {
|
||||||
isVirtualParent = ArchiveHandlerManager.isVirtual(remoteParent);
|
isVirtualParent = ArchiveHandlerManager.isVirtual(remoteParent);
|
||||||
|
@ -841,8 +843,8 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
|
||||||
}
|
}
|
||||||
if (!isVirtualParent && !isArchiveParent)
|
if (!isVirtualParent && !isArchiveParent)
|
||||||
{
|
{
|
||||||
File file = remoteParent==null ? new File(name) : new File(remoteParent, name);
|
File file = isRoot ? new File(name) : new File(remoteParent, name);
|
||||||
return new LocalHostFile(file);
|
return new LocalHostFile(file, isRoot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [218042] Support UNIX permission modification on ssh
|
* Martin Oberhuber (Wind River) - [218042] Support UNIX permission modification on ssh
|
||||||
* Martin Oberhuber (Wind River) - [233651] Make ssh delete throw proper exceptions
|
* Martin Oberhuber (Wind River) - [233651] Make ssh delete throw proper exceptions
|
||||||
* Martin Oberhuber (Wind River) - [235477][ssh] SftpFileService.createFolder() fails for file named "a?*"
|
* Martin Oberhuber (Wind River) - [235477][ssh] SftpFileService.createFolder() fails for file named "a?*"
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh.files;
|
package org.eclipse.rse.internal.services.ssh.files;
|
||||||
|
@ -446,6 +447,10 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
*/
|
*/
|
||||||
protected String concat(String parentDir, String fileName) {
|
protected String concat(String parentDir, String fileName) {
|
||||||
// See also {@link SftpHostFile#getAbsolutePath()}
|
// See also {@link SftpHostFile#getAbsolutePath()}
|
||||||
|
if (parentDir == null || parentDir.length() == 0) {
|
||||||
|
// Looking at a Root
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
StringBuffer path = new StringBuffer(parentDir);
|
StringBuffer path = new StringBuffer(parentDir);
|
||||||
if (!parentDir.endsWith("/")) //$NON-NLS-1$
|
if (!parentDir.endsWith("/")) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
|
@ -483,7 +488,8 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
throw new SystemLockTimeoutException(Activator.PLUGIN_ID);
|
throw new SystemLockTimeoutException(Activator.PLUGIN_ID);
|
||||||
}
|
}
|
||||||
if (node==null) {
|
if (node==null) {
|
||||||
node = new SftpHostFile(remoteParent, fileName, false, false, false, 0, 0);
|
boolean isRoot = (remoteParent == null || remoteParent.length() == 0);
|
||||||
|
node = new SftpHostFile(remoteParent, fileName, false, isRoot, false, 0, 0);
|
||||||
node.setExists(false);
|
node.setExists(false);
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
|
@ -566,8 +572,9 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
SftpATTRS attrsTarget = attrs;
|
SftpATTRS attrsTarget = attrs;
|
||||||
String linkTarget=null;
|
String linkTarget=null;
|
||||||
String canonicalPath = null;
|
String canonicalPath = null;
|
||||||
if (attrs.isLink()) {
|
boolean isRoot = (parentPath == null || parentPath.length() == 0);
|
||||||
//check if the link points to a directory
|
if (attrs.isLink() && !isRoot) {
|
||||||
|
//check if the link points to a directory. Roots cannot be Links.
|
||||||
try {
|
try {
|
||||||
String fullPath = concat(parentPath, fileName);
|
String fullPath = concat(parentPath, fileName);
|
||||||
boolean readlinkDone = false;
|
boolean readlinkDone = false;
|
||||||
|
@ -615,8 +622,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SftpHostFile node = new SftpHostFile(parentPath, fileName, attrsTarget.isDir(), isRoot, attrs.isLink(), 1000L * attrs.getMTime(), attrs.getSize());
|
||||||
SftpHostFile node = new SftpHostFile(parentPath, fileName, attrsTarget.isDir(), false, attrs.isLink(), 1000L * attrs.getMTime(), attrs.getSize());
|
|
||||||
if (linkTarget!=null) {
|
if (linkTarget!=null) {
|
||||||
node.setLinkTarget(linkTarget);
|
node.setLinkTarget(linkTarget);
|
||||||
}
|
}
|
||||||
|
@ -848,7 +854,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
//Returning the home path as a Root is the safest we can do, since it will
|
//Returning the home path as a Root is the safest we can do, since it will
|
||||||
//let users know what the home path is, and the "My Home" filter will be
|
//let users know what the home path is, and the "My Home" filter will be
|
||||||
//set to correct target. See also bug 204710.
|
//set to correct target. See also bug 204710.
|
||||||
return new SftpHostFile("", fUserHome, true, true, false, 0, 0); //$NON-NLS-1$
|
return new SftpHostFile(null, fUserHome, true, true, false, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Bug 203490, bug 204710: Could not determine user home
|
//Bug 203490, bug 204710: Could not determine user home
|
||||||
|
@ -856,7 +862,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostFile[] getRoots(IProgressMonitor monitor) {
|
public IHostFile[] getRoots(IProgressMonitor monitor) {
|
||||||
IHostFile root = new SftpHostFile("/", "/", true, true, false, 0, 0); //$NON-NLS-1$ //$NON-NLS-2$
|
IHostFile root = new SftpHostFile(null, "/", true, true, false, 0, 0); //$NON-NLS-1$
|
||||||
return new IHostFile[] { root };
|
return new IHostFile[] { root };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - Adapted from FTPHostFile.
|
* Martin Oberhuber (Wind River) - Adapted from FTPHostFile.
|
||||||
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
* David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh.files;
|
package org.eclipse.rse.internal.services.ssh.files;
|
||||||
|
@ -49,6 +50,9 @@ public class SftpHostFile implements IHostFile, IHostFilePermissionsContainer {
|
||||||
public SftpHostFile(String parentPath, String name, boolean isDirectory, boolean isRoot, boolean isLink, long lastModified, long size) {
|
public SftpHostFile(String parentPath, String name, boolean isDirectory, boolean isRoot, boolean isLink, long lastModified, long size) {
|
||||||
fParentPath = parentPath;
|
fParentPath = parentPath;
|
||||||
fName = name;
|
fName = name;
|
||||||
|
if (name == null || name.length() == 0) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
fIsDirectory = isDirectory;
|
fIsDirectory = isDirectory;
|
||||||
fIsRoot = isRoot;
|
fIsRoot = isRoot;
|
||||||
fLastModified = lastModified;
|
fLastModified = lastModified;
|
||||||
|
@ -115,9 +119,25 @@ public class SftpHostFile implements IHostFile, IHostFilePermissionsContainer {
|
||||||
public void renameTo(String newAbsolutePath) {
|
public void renameTo(String newAbsolutePath) {
|
||||||
int i = newAbsolutePath.lastIndexOf("/"); //$NON-NLS-1$
|
int i = newAbsolutePath.lastIndexOf("/"); //$NON-NLS-1$
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
|
//Rename inside the same parent folder.
|
||||||
|
//FIXME is this really what was desired here? Or would we rename Roots?
|
||||||
|
//Renaming Roots isn't possible, I'd think.
|
||||||
fName = newAbsolutePath;
|
fName = newAbsolutePath;
|
||||||
}
|
}
|
||||||
else {
|
else if (i == 0) {
|
||||||
|
// Renaming a root folder
|
||||||
|
if (newAbsolutePath.length()==1) {
|
||||||
|
//rename to root "/" -- should this work?
|
||||||
|
fParentPath = null;
|
||||||
|
fIsRoot = true;
|
||||||
|
fName = newAbsolutePath;
|
||||||
|
} else {
|
||||||
|
fParentPath = "/"; //$NON-NLS-1$
|
||||||
|
fName = newAbsolutePath.substring(i + 1);
|
||||||
|
}
|
||||||
|
fParentPath = "/"; //$NON-NLS-1$
|
||||||
|
fName = newAbsolutePath.substring(i + 1);
|
||||||
|
} else {
|
||||||
fParentPath = newAbsolutePath.substring(0, i);
|
fParentPath = newAbsolutePath.substring(0, i);
|
||||||
fName = newAbsolutePath.substring(i+1);
|
fName = newAbsolutePath.substring(i+1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [221211] Fix markStale() for delete() operation with exceptions
|
* Martin Oberhuber (Wind River) - [221211] Fix markStale() for delete() operation with exceptions
|
||||||
* David Dykstal (IBM) - [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
|
* David Dykstal (IBM) - [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
|
||||||
* Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions
|
* Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions
|
||||||
|
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
|
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
|
||||||
|
@ -326,8 +327,9 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
|
||||||
}
|
}
|
||||||
|
|
||||||
IRemoteFile parent = null;
|
IRemoteFile parent = null;
|
||||||
if (!userHome.getParentPath().equals(".")) //$NON-NLS-1$
|
if (!".".equals(userHome.getParentPath())) //$NON-NLS-1$
|
||||||
{
|
{
|
||||||
|
//note: parent path can be "null" if userHome is a Root
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//parent = getRemoteFileObject(userHome.getParentPath());
|
//parent = getRemoteFileObject(userHome.getParentPath());
|
||||||
|
|
Loading…
Add table
Reference in a new issue