mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
[331213] Checked in additional refactoring for scp.
This commit is contained in:
parent
6251313e62
commit
d359414881
7 changed files with 135 additions and 101 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc.
|
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE
|
* Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE
|
||||||
* Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2)
|
* Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2)
|
||||||
* Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing
|
* Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing
|
||||||
|
* Anna Dushistova (MontaVista) - [331213] [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh;
|
package org.eclipse.rse.internal.services.ssh;
|
||||||
|
@ -19,6 +20,26 @@ import org.eclipse.osgi.util.NLS;
|
||||||
public class SshServiceResources extends NLS {
|
public class SshServiceResources extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.rse.internal.services.ssh.SshServiceResources"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.rse.internal.services.ssh.SshServiceResources"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static String ScpFileService_AttributesError;
|
||||||
|
|
||||||
|
public static String ScpFileService_Description;
|
||||||
|
|
||||||
|
public static String ScpFileService_DownloadFileTaskName;
|
||||||
|
|
||||||
|
public static String ScpFileService_LastModifiedNotSupportedError;
|
||||||
|
|
||||||
|
public static String ScpFileService_Name;
|
||||||
|
|
||||||
|
public static String ScpFileService_ReadAckError;
|
||||||
|
|
||||||
|
public static String ScpFileService_UploadFileTaskName;
|
||||||
|
|
||||||
|
public static String ScpFileService_DownloadException;
|
||||||
|
|
||||||
|
public static String ScpFileService_DownloadException1;
|
||||||
|
|
||||||
|
public static String ScpFileService_UploadException;
|
||||||
|
|
||||||
public static String SftpFileService_Name;
|
public static String SftpFileService_Name;
|
||||||
public static String SftpFileService_Description;
|
public static String SftpFileService_Description;
|
||||||
public static String SftpFileService_Error_JschSessionLost;
|
public static String SftpFileService_Error_JschSessionLost;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
# Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -10,11 +10,23 @@
|
||||||
# Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE
|
# Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE
|
||||||
# Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2)
|
# Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2)
|
||||||
# Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing
|
# Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing
|
||||||
|
# Anna Dushistova (MontaVista) - [331213] [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# NLS_MESSAGEFORMAT_VAR
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
# NLS_ENCODING=UTF-8
|
# NLS_ENCODING=UTF-8
|
||||||
|
|
||||||
|
ScpFileService_AttributesError=Can't get attribute of file
|
||||||
|
ScpFileService_Description=SSH/SCP File Service can be used to connect to embedded sshd implementations, which often lacks sftp service
|
||||||
|
ScpFileService_DownloadFileTaskName=Downloading file
|
||||||
|
ScpFileService_LastModifiedNotSupportedError=setLastModified() not supported
|
||||||
|
ScpFileService_Name=SCP File Service
|
||||||
|
ScpFileService_ReadAckError=upload: wrong Ack\! Last error:
|
||||||
|
ScpFileService_UploadFileTaskName=Uploading file
|
||||||
|
ScpFileService_DownloadException=Error happened while downloading {0}: {1}
|
||||||
|
ScpFileService_DownloadException1=Error happened while downloading {0}: Can't download file of type {1}
|
||||||
|
ScpFileService_UploadException=Error happened while uploading {0}: {1}
|
||||||
|
|
||||||
SshPlugin_Unexpected_Exception=Unexpected {0}: {1}
|
SshPlugin_Unexpected_Exception=Unexpected {0}: {1}
|
||||||
|
|
||||||
SftpFileService_Name=Ssh / Sftp File Service
|
SftpFileService_Name=Ssh / Sftp File Service
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -39,9 +39,10 @@
|
||||||
* David McKnight (IBM) - [271244] [sftp files] "My Home" filter not working
|
* David McKnight (IBM) - [271244] [sftp files] "My Home" filter not working
|
||||||
* David McKnight (IBM) - [272882] [api] Handle exceptions in IService.initService()
|
* David McKnight (IBM) - [272882] [api] Handle exceptions in IService.initService()
|
||||||
* Martin Oberhuber (Wind River) - [274568] Dont use SftpMonitor for Streams transfer
|
* Martin Oberhuber (Wind River) - [274568] Dont use SftpMonitor for Streams transfer
|
||||||
* Patrick Tassé (Ericsson) - [285226] Empty directory shown as an error message
|
* Patrick Tass� (Ericsson) - [285226] Empty directory shown as an error message
|
||||||
* Martin Oberhuber (Wind River) - [286129][api] RemoteFileException(String) violates API contract
|
* Martin Oberhuber (Wind River) - [286129][api] RemoteFileException(String) violates API contract
|
||||||
* Martin Tauber - [256581][performance] Re-use Sftp channels
|
* Martin Tauber - [256581][performance] Re-use Sftp channels
|
||||||
|
* Anna Dushistova (MontaVista) - [331213] [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh.files;
|
package org.eclipse.rse.internal.services.ssh.files;
|
||||||
|
@ -607,18 +608,7 @@ 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()}
|
return SshFileUtils.concat(parentDir, fileName);
|
||||||
if (parentDir == null || parentDir.length() == 0) {
|
|
||||||
// Looking at a Root
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
StringBuffer path = new StringBuffer(parentDir);
|
|
||||||
if (!parentDir.endsWith("/")) //$NON-NLS-1$
|
|
||||||
{
|
|
||||||
path.append('/');
|
|
||||||
}
|
|
||||||
path.append(fileName);
|
|
||||||
return path.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHostFile getFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
public IHostFile getFile(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2010 Mentor Graphics Corporation and others.
|
* Copyright (c) 2009, 2012 Mentor Graphics Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,19 +8,24 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Nikita Shulga - initial API and implementation
|
* Nikita Shulga - initial API and implementation
|
||||||
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
|
* Anna Dushistova (MontaVista) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
package org.eclipse.rse.internal.services.ssh.files;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
|
||||||
|
import org.eclipse.rse.internal.services.ssh.Activator;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
|
|
||||||
import com.jcraft.jsch.ChannelExec;
|
import com.jcraft.jsch.ChannelExec;
|
||||||
import com.jcraft.jsch.Session;
|
import com.jcraft.jsch.Session;
|
||||||
|
|
||||||
public class ScpFileUtils {
|
public class SshFileUtils {
|
||||||
public static final String EOL_STRING = "\n"; //$NON-NLS-1$
|
public static final String EOL_STRING = "\n"; //$NON-NLS-1$
|
||||||
public static final String TARGET_SEPARATOR = "/"; //$NON-NLS-1$
|
public static final String TARGET_SEPARATOR = "/"; //$NON-NLS-1$
|
||||||
public static final String EXEC_CHANNEL = "exec"; //$NON-NLS-1$
|
public static final String EXEC_CHANNEL = "exec"; //$NON-NLS-1$
|
||||||
|
@ -33,10 +38,10 @@ public class ScpFileUtils {
|
||||||
* Concatenate a parent directory with a file name to form a new proper path
|
* Concatenate a parent directory with a file name to form a new proper path
|
||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* This method was cloned from
|
* This method was moved from
|
||||||
* org.eclipse.rse.services.ssh / SftpFileService#concat()
|
* org.eclipse.rse.services.ssh / SftpFileService#concat()
|
||||||
*/
|
*/
|
||||||
protected static String concat(String parentDir, String fileName) {
|
public static String concat(String parentDir, String fileName) {
|
||||||
// See also {@link SftpHostFile#getAbsolutePath()}
|
// See also {@link SftpHostFile#getAbsolutePath()}
|
||||||
if (parentDir == null || parentDir.length() == 0) {
|
if (parentDir == null || parentDir.length() == 0) {
|
||||||
// Looking at a Root
|
// Looking at a Root
|
||||||
|
@ -83,7 +88,7 @@ public class ScpFileUtils {
|
||||||
try {
|
try {
|
||||||
rc = execCommand(session, command);
|
rc = execCommand(session, command);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ScpFileService.throwSystemException(e);
|
throwSystemException(e);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +109,7 @@ public class ScpFileUtils {
|
||||||
* file name
|
* file name
|
||||||
* @return escaped concatenated path to the file
|
* @return escaped concatenated path to the file
|
||||||
*/
|
*/
|
||||||
protected static String concatEscape(String parentDir, String fileName) {
|
public static String concatEscape(String parentDir, String fileName) {
|
||||||
return escapePath(concat(parentDir, fileName));
|
return escapePath(concat(parentDir, fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,4 +138,14 @@ public class ScpFileUtils {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void throwSystemException(Exception e)
|
||||||
|
throws SystemMessageException {
|
||||||
|
Activator.warn("SshFileUtils.throwSystemException", e); //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (e instanceof SystemMessageException)
|
||||||
|
throw (SystemMessageException) e;
|
||||||
|
throw new SystemMessageException(new SimpleSystemMessage(
|
||||||
|
Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Mentor Graphics Corporation and others.
|
* Copyright (c) 2009, 2012 Mentor Graphics Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Nikita Shulga - initial API and implementation
|
* Nikita Shulga - initial API and implementation
|
||||||
* Nikita Shulga (Mentor Graphics) - [331109] Added long-iso time format support
|
* Nikita Shulga (Mentor Graphics) - [331109] Added long-iso time format support
|
||||||
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
|
* Anna Dushistova (MontaVista) - [331213] [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
package org.eclipse.rse.internal.services.ssh.files.scp;
|
||||||
|
@ -21,6 +22,7 @@ import java.util.Stack;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.rse.internal.services.ssh.Activator;
|
import org.eclipse.rse.internal.services.ssh.Activator;
|
||||||
|
import org.eclipse.rse.internal.services.ssh.files.SshFileUtils;
|
||||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
import org.eclipse.rse.services.files.HostFilePermissions;
|
import org.eclipse.rse.services.files.HostFilePermissions;
|
||||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||||
|
@ -133,7 +135,7 @@ public class ScpFileAttr {
|
||||||
SplitAux();
|
SplitAux();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.warn(
|
Activator.warn(
|
||||||
"ScpFileAttr:Exception occured while splitting string "
|
"ScpFileAttr:Exception occured while splitting string " //$NON-NLS-1$
|
||||||
+ lsString, e);
|
+ lsString, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,8 +262,8 @@ public class ScpFileAttr {
|
||||||
|
|
||||||
public static ScpFileAttr getAttr(Session sess, String path)
|
public static ScpFileAttr getAttr(Session sess, String path)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
String attr = ScpFileUtils.execCommandSafe(sess, "ls -land " //$NON-NLS-1$
|
String attr = SshFileUtils.execCommandSafe(sess, "ls -land " //$NON-NLS-1$
|
||||||
+ ScpFileUtils.escapePath(path));
|
+ SshFileUtils.escapePath(path));
|
||||||
if (attr == null || attr.length() < 9)
|
if (attr == null || attr.length() < 9)
|
||||||
return null;
|
return null;
|
||||||
return new ScpFileAttr(attr);
|
return new ScpFileAttr(attr);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Mentor Graphics Corporation and others.
|
* Copyright (c) 2009, 2012 Mentor Graphics Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
* Anna Dushistova (Mentor Graphics) - [331249][scp] incorrect home while logging in as root
|
* Anna Dushistova (Mentor Graphics) - [331249][scp] incorrect home while logging in as root
|
||||||
* Simon Bernard (Sierra Wireless) - [349947][scp] with scp IRemoteFile.exist() returns always true
|
* Simon Bernard (Sierra Wireless) - [349947][scp] with scp IRemoteFile.exist() returns always true
|
||||||
|
* Anna Dushistova (MontaVista) - [331213] [scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
package org.eclipse.rse.internal.services.ssh.files.scp;
|
||||||
|
|
||||||
|
@ -24,9 +25,12 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
import org.eclipse.rse.internal.services.ssh.Activator;
|
import org.eclipse.rse.internal.services.ssh.Activator;
|
||||||
import org.eclipse.rse.internal.services.ssh.ISshSessionProvider;
|
import org.eclipse.rse.internal.services.ssh.ISshSessionProvider;
|
||||||
|
import org.eclipse.rse.internal.services.ssh.SshServiceResources;
|
||||||
|
import org.eclipse.rse.internal.services.ssh.files.SshFileUtils;
|
||||||
import org.eclipse.rse.internal.services.ssh.files.SftpHostFile;
|
import org.eclipse.rse.internal.services.ssh.files.SftpHostFile;
|
||||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||||
|
@ -67,16 +71,6 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
Activator.PLUGIN_ID, IStatus.ERROR, msg));
|
Activator.PLUGIN_ID, IStatus.ERROR, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void throwSystemException(Exception e)
|
|
||||||
throws SystemMessageException {
|
|
||||||
Activator.warn("ScpFileServie.throwSystemExcpeption", e);
|
|
||||||
|
|
||||||
if (e instanceof SystemMessageException)
|
|
||||||
throw (SystemMessageException) e;
|
|
||||||
throw new SystemMessageException(new SimpleSystemMessage(
|
|
||||||
Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IHostFile[] internalFetch(String parentPath, String fileFilter,
|
protected IHostFile[] internalFetch(String parentPath, String fileFilter,
|
||||||
int fileType, IProgressMonitor monitor)
|
int fileType, IProgressMonitor monitor)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
|
@ -93,17 +87,17 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
|
|
||||||
List results = new ArrayList();
|
List results = new ArrayList();
|
||||||
Session sess = getSession();
|
Session sess = getSession();
|
||||||
String cmd = "ls -lAn " + ScpFileUtils.escapePath(parentPath); //$NON-NLS-1$
|
String cmd = "ls -lAn " + SshFileUtils.escapePath(parentPath); //$NON-NLS-1$
|
||||||
|
|
||||||
String rc = ScpFileUtils.execCommandSafe(sess, cmd);
|
String rc = SshFileUtils.execCommandSafe(sess, cmd);
|
||||||
String[] lsStrings = rc.split(ScpFileUtils.EOL_STRING);
|
String[] lsStrings = rc.split(SshFileUtils.EOL_STRING);
|
||||||
for (int i=0;i<lsStrings.length;i++){
|
for (int i=0;i<lsStrings.length;i++){
|
||||||
if (lsStrings[i].length() == 0 || lsStrings[i].startsWith("total")) //$NON-NLS-1$
|
if (lsStrings[i].length() == 0 || lsStrings[i].startsWith("total")) //$NON-NLS-1$
|
||||||
continue;
|
continue;
|
||||||
ScpFileAttr attr = new ScpFileAttr(lsStrings[i]);
|
ScpFileAttr attr = new ScpFileAttr(lsStrings[i]);
|
||||||
if (attr.getName() == null) {
|
if (attr.getName() == null) {
|
||||||
Activator.warn("internalFetch(parentPath='" + parentPath
|
Activator.warn("internalFetch(parentPath='" + parentPath //$NON-NLS-1$
|
||||||
+ "'): Can't get name of " + lsStrings[i], null);
|
+ "'): Can't get name of " + lsStrings[i], null); //$NON-NLS-1$
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!filematcher.matches(attr.getName()))
|
if (!filematcher.matches(attr.getName()))
|
||||||
|
@ -132,13 +126,13 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
IHostFilePermissions permissions, IProgressMonitor monitor)
|
IHostFilePermissions permissions, IProgressMonitor monitor)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String path = ScpFileUtils.escapePath(file.getAbsolutePath());
|
String path = SshFileUtils.escapePath(file.getAbsolutePath());
|
||||||
int permBits = permissions.getPermissionBits();
|
int permBits = permissions.getPermissionBits();
|
||||||
String ownStr = permissions.getUserOwner() + ':'
|
String ownStr = permissions.getUserOwner() + ':'
|
||||||
+ permissions.getGroupOwner();
|
+ permissions.getGroupOwner();
|
||||||
String cmd = "chmod " + Integer.toOctalString(permBits) + " " + path; //$NON-NLS-1$ //$NON-NLS-2$
|
String cmd = "chmod " + Integer.toOctalString(permBits) + " " + path; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
ScpFileUtils.execCommandSafe(session, cmd);
|
SshFileUtils.execCommandSafe(session, cmd);
|
||||||
ScpFileUtils.execCommandSafe(session, "chown " + ownStr + " " + path); //$NON-NLS-1$ //$NON-NLS-2$
|
SshFileUtils.execCommandSafe(session, "chown " + ownStr + " " + path); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copy(String arg0, String arg1, String arg2, String arg3,
|
public void copy(String arg0, String arg1, String arg2, String arg3,
|
||||||
|
@ -156,10 +150,10 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
public IHostFile createFile(String remotePath, String fileName,
|
public IHostFile createFile(String remotePath, String fileName,
|
||||||
IProgressMonitor arg2) throws SystemMessageException {
|
IProgressMonitor arg2) throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String fullPath = ScpFileUtils.concat(remotePath, fileName);
|
String fullPath = SshFileUtils.concat(remotePath, fileName);
|
||||||
|
|
||||||
ScpFileUtils.execCommandSafe(session,
|
SshFileUtils.execCommandSafe(session,
|
||||||
"touch " + ScpFileUtils.escapePath(fullPath)); //$NON-NLS-1$
|
"touch " + SshFileUtils.escapePath(fullPath)); //$NON-NLS-1$
|
||||||
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
||||||
|
|
||||||
return makeHostFile(remotePath, fileName, attr);
|
return makeHostFile(remotePath, fileName, attr);
|
||||||
|
@ -168,10 +162,10 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
public IHostFile createFolder(String remotePath, String fileName,
|
public IHostFile createFolder(String remotePath, String fileName,
|
||||||
IProgressMonitor arg2) throws SystemMessageException {
|
IProgressMonitor arg2) throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String fullPath = ScpFileUtils.concat(remotePath, fileName);
|
String fullPath = SshFileUtils.concat(remotePath, fileName);
|
||||||
|
|
||||||
ScpFileUtils.execCommandSafe(session,
|
SshFileUtils.execCommandSafe(session,
|
||||||
"mkdir " + ScpFileUtils.escapePath(fullPath)); //$NON-NLS-1$
|
"mkdir " + SshFileUtils.escapePath(fullPath)); //$NON-NLS-1$
|
||||||
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
||||||
|
|
||||||
return makeHostFile(remotePath, fileName, attr);
|
return makeHostFile(remotePath, fileName, attr);
|
||||||
|
@ -180,9 +174,9 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
public void delete(String remotePath, String fileName, IProgressMonitor arg2)
|
public void delete(String remotePath, String fileName, IProgressMonitor arg2)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String fullPathEsc = ScpFileUtils.concatEscape(remotePath, fileName);
|
String fullPathEsc = SshFileUtils.concatEscape(remotePath, fileName);
|
||||||
|
|
||||||
ScpFileUtils.execCommandSafe(session, "rm -rf " + fullPathEsc); //$NON-NLS-1$
|
SshFileUtils.execCommandSafe(session, "rm -rf " + fullPathEsc); //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +201,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
do {
|
do {
|
||||||
ch = is.read();
|
ch = is.read();
|
||||||
sb.append((char) ch);
|
sb.append((char) ch);
|
||||||
} while (ch != ScpFileUtils.EOL_CHAR);
|
} while (ch != SshFileUtils.EOL_CHAR);
|
||||||
setErrorMessage(sb.toString());
|
setErrorMessage(sb.toString());
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +221,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
internalDownload(remoteParent, fileName, localFile, monitor);
|
internalDownload(remoteParent, fileName, localFile, monitor);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throwSystemException(e);
|
SshFileUtils.throwSystemException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -235,7 +229,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
public IHostFile getFile(String remotePath, String fileName,
|
public IHostFile getFile(String remotePath, String fileName,
|
||||||
IProgressMonitor monitor) throws SystemMessageException {
|
IProgressMonitor monitor) throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String fullPath = ScpFileUtils.concat(remotePath, fileName);
|
String fullPath = SshFileUtils.concat(remotePath, fileName);
|
||||||
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
||||||
|
|
||||||
return makeHostFile(remotePath, fileName, attr);
|
return makeHostFile(remotePath, fileName, attr);
|
||||||
|
@ -245,12 +239,12 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
IHostFile root = null;
|
IHostFile root = null;
|
||||||
try {
|
try {
|
||||||
root = getFile(null, ScpFileUtils.TARGET_SEPARATOR, monitor);
|
root = getFile(null, SshFileUtils.TARGET_SEPARATOR, monitor);
|
||||||
} catch (SystemMessageException e) {
|
} catch (SystemMessageException e) {
|
||||||
Activator.warn("Failed to get root file", e);
|
Activator.warn("Failed to get root file", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (root == null)
|
if (root == null)
|
||||||
root = new SftpHostFile(null, ScpFileUtils.TARGET_SEPARATOR, true,
|
root = new SftpHostFile(null, SshFileUtils.TARGET_SEPARATOR, true,
|
||||||
true, false, 0, 0);
|
true, false, 0, 0);
|
||||||
|
|
||||||
return new IHostFile[] { root };
|
return new IHostFile[] { root };
|
||||||
|
@ -261,24 +255,24 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
if (fUserHome == null) {
|
if (fUserHome == null) {
|
||||||
try {
|
try {
|
||||||
Session sess = getSession();
|
Session sess = getSession();
|
||||||
fUserHome = ScpFileUtils.execCommand(sess, "cd ;pwd").split( //$NON-NLS-1$
|
fUserHome = SshFileUtils.execCommand(sess, "cd ;pwd").split( //$NON-NLS-1$
|
||||||
ScpFileUtils.EOL_STRING)[0];
|
SshFileUtils.EOL_STRING)[0];
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Activator.warn("Failed to execute pwd", e);
|
Activator.warn("Failed to execute pwd", e); //$NON-NLS-1$
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fUserHome == null)
|
if (fUserHome == null)
|
||||||
return null;
|
return null;
|
||||||
int lastSlash = fUserHome
|
int lastSlash = fUserHome
|
||||||
.lastIndexOf(ScpFileUtils.TARGET_SEPARATOR_CHAR);
|
.lastIndexOf(SshFileUtils.TARGET_SEPARATOR_CHAR);
|
||||||
String name = fUserHome.substring(lastSlash + 1);
|
String name = fUserHome.substring(lastSlash + 1);
|
||||||
String parent = fUserHome.substring(0, lastSlash+1);
|
String parent = fUserHome.substring(0, lastSlash+1);
|
||||||
IHostFile rc = null;
|
IHostFile rc = null;
|
||||||
try {
|
try {
|
||||||
rc = getFile(parent, name, null);
|
rc = getFile(parent, name, null);
|
||||||
} catch (SystemMessageException e) {
|
} catch (SystemMessageException e) {
|
||||||
Activator.warn("Failed to get user home file ", e);
|
Activator.warn("Failed to get user home file ", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (rc == null)
|
if (rc == null)
|
||||||
rc = new SftpHostFile(null, fUserHome, true, true, false, 0, 0);
|
rc = new SftpHostFile(null, fUserHome, true, true, false, 0, 0);
|
||||||
|
@ -293,20 +287,20 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
String newName, IProgressMonitor arg4)
|
String newName, IProgressMonitor arg4)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String oldFullPathEsc = ScpFileUtils.concatEscape(newPath, oldName);
|
String oldFullPathEsc = SshFileUtils.concatEscape(newPath, oldName);
|
||||||
String newFullPathEsc = ScpFileUtils.concatEscape(newPath, newName);
|
String newFullPathEsc = SshFileUtils.concatEscape(newPath, newName);
|
||||||
|
|
||||||
ScpFileUtils.execCommandSafe(session, "mv " + oldFullPathEsc + " " //$NON-NLS-1$ //$NON-NLS-2$
|
SshFileUtils.execCommandSafe(session, "mv " + oldFullPathEsc + " " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ newFullPathEsc);
|
+ newFullPathEsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rename(String remotePath, String oldName, String newName,
|
public void rename(String remotePath, String oldName, String newName,
|
||||||
IProgressMonitor monitor) throws SystemMessageException {
|
IProgressMonitor monitor) throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String oldFullPathEsc = ScpFileUtils.concatEscape(remotePath, oldName);
|
String oldFullPathEsc = SshFileUtils.concatEscape(remotePath, oldName);
|
||||||
String newFullPathEsc = ScpFileUtils.concatEscape(remotePath, newName);
|
String newFullPathEsc = SshFileUtils.concatEscape(remotePath, newName);
|
||||||
|
|
||||||
ScpFileUtils.execCommandSafe(session, "mv " + oldFullPathEsc + " " //$NON-NLS-1$ //$NON-NLS-2$
|
SshFileUtils.execCommandSafe(session, "mv " + oldFullPathEsc + " " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ newFullPathEsc);
|
+ newFullPathEsc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -320,27 +314,27 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
|
|
||||||
public void setLastModified(String arg0, String arg1, long arg2,
|
public void setLastModified(String arg0, String arg1, long arg2,
|
||||||
IProgressMonitor arg3) throws SystemMessageException {
|
IProgressMonitor arg3) throws SystemMessageException {
|
||||||
throwSystemException("setLastModified() not supported");
|
throwSystemException(SshServiceResources.ScpFileService_LastModifiedNotSupportedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReadOnly(String remotePath, String fileName,
|
public void setReadOnly(String remotePath, String fileName,
|
||||||
boolean disableWrite, IProgressMonitor monitor)
|
boolean disableWrite, IProgressMonitor monitor)
|
||||||
throws SystemMessageException {
|
throws SystemMessageException {
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String fullPath = ScpFileUtils.concat(remotePath, fileName);
|
String fullPath = SshFileUtils.concat(remotePath, fileName);
|
||||||
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
ScpFileAttr attr = ScpFileAttr.getAttr(session, fullPath);
|
||||||
if (attr == null)
|
if (attr == null)
|
||||||
throwSystemException("Can't get attribute of file " + fullPath);
|
throwSystemException(SshServiceResources.ScpFileService_AttributesError + fullPath);
|
||||||
int perm = new HostFilePermissions(attr.getAttrs(), "", "") //$NON-NLS-1$ //$NON-NLS-2$
|
int perm = new HostFilePermissions(attr.getAttrs(), "", "") //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
.getPermissionBits();
|
.getPermissionBits();
|
||||||
if (disableWrite)
|
if (disableWrite)
|
||||||
perm &= ~0222;
|
perm &= ~0222;
|
||||||
else
|
else
|
||||||
perm |= 0200;
|
perm |= 0200;
|
||||||
ScpFileUtils.execCommandSafe(
|
SshFileUtils.execCommandSafe(
|
||||||
session,
|
session,
|
||||||
"chmod " + Integer.toOctalString(perm) + " " //$NON-NLS-1$//$NON-NLS-2$
|
"chmod " + Integer.toOctalString(perm) + " " //$NON-NLS-1$//$NON-NLS-2$
|
||||||
+ ScpFileUtils.escapePath(fullPath));
|
+ SshFileUtils.escapePath(fullPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void upload(InputStream stream, String remotePath,
|
public void upload(InputStream stream, String remotePath,
|
||||||
|
@ -351,10 +345,10 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
|
|
||||||
private void internalDownload(String remoteParent, String fileName,
|
private void internalDownload(String remoteParent, String fileName,
|
||||||
File localFile, IProgressMonitor monitor) throws Exception {
|
File localFile, IProgressMonitor monitor) throws Exception {
|
||||||
String remotePath = ScpFileUtils.concat(remoteParent, fileName);
|
String remotePath = SshFileUtils.concat(remoteParent, fileName);
|
||||||
String cmd = "scp -f " + ScpFileUtils.escapePath(remotePath); //$NON-NLS-1$
|
String cmd = "scp -f " + SshFileUtils.escapePath(remotePath); //$NON-NLS-1$
|
||||||
|
|
||||||
ChannelExec ch = ScpFileUtils.openExecChannel(getSession(), cmd);
|
ChannelExec ch = SshFileUtils.openExecChannel(getSession(), cmd);
|
||||||
InputStream is = ch.getInputStream();
|
InputStream is = ch.getInputStream();
|
||||||
OutputStream os = ch.getOutputStream();
|
OutputStream os = ch.getOutputStream();
|
||||||
ch.connect();
|
ch.connect();
|
||||||
|
@ -367,13 +361,12 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
|
|
||||||
int c = is.read();
|
int c = is.read();
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
String errmsg = ScpFileUtils.readString(is);
|
String errmsg = SshFileUtils.readString(is);
|
||||||
throw new Exception("Error while downloading " + remotePath + " :"
|
throw new Exception(NLS.bind(SshServiceResources.ScpFileService_DownloadException,remotePath,
|
||||||
+ errmsg);
|
errmsg));
|
||||||
}
|
}
|
||||||
if (c != 'C')
|
if (c != 'C')
|
||||||
throw new Exception("Error while downloading " + remotePath
|
throw new Exception(NLS.bind(SshServiceResources.ScpFileService_DownloadException1,remotePath, ""+c)); //$NON-NLS-1$
|
||||||
+ ": Can't download file of type" + c);
|
|
||||||
|
|
||||||
// read '0644'
|
// read '0644'
|
||||||
is.read(buf, 0, 5);
|
is.read(buf, 0, 5);
|
||||||
|
@ -387,9 +380,9 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
break;
|
break;
|
||||||
filesize = filesize * 10 + (buf[0] - '0');
|
filesize = filesize * 10 + (buf[0] - '0');
|
||||||
}
|
}
|
||||||
String fname = ScpFileUtils.readString(is);
|
String fname = SshFileUtils.readString(is);
|
||||||
|
|
||||||
Activator.log("filesize=" + filesize + " fname=" + fname);
|
Activator.log("filesize=" + filesize + " fname=" + fname); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
// Confirm that file description is read by sending '0'
|
// Confirm that file description is read by sending '0'
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
@ -397,7 +390,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
os.flush();
|
os.flush();
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(localFile);
|
FileOutputStream fos = new FileOutputStream(localFile);
|
||||||
monitor.beginTask("Downloading file", (int) filesize);
|
monitor.beginTask(SshServiceResources.ScpFileService_DownloadFileTaskName, (int) filesize);
|
||||||
long bytesDownloaded = 0;
|
long bytesDownloaded = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int len = buf.length;
|
int len = buf.length;
|
||||||
|
@ -433,11 +426,11 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
private void internalUpload(File localFile, String remotePath,
|
private void internalUpload(File localFile, String remotePath,
|
||||||
String remoteFile, IProgressMonitor monitor) throws Exception {
|
String remoteFile, IProgressMonitor monitor) throws Exception {
|
||||||
|
|
||||||
monitor.beginTask("Uploading file", (int) localFile.length() + 10);
|
monitor.beginTask(SshServiceResources.ScpFileService_UploadFileTaskName, (int) localFile.length() + 10);
|
||||||
|
|
||||||
Session session = getSession();
|
Session session = getSession();
|
||||||
String cmd = "scp -p -t " + ScpFileUtils.escapePath(remotePath); //$NON-NLS-1$
|
String cmd = "scp -p -t " + SshFileUtils.escapePath(remotePath); //$NON-NLS-1$
|
||||||
ChannelExec ch = ScpFileUtils.openExecChannel(session, cmd);
|
ChannelExec ch = SshFileUtils.openExecChannel(session, cmd);
|
||||||
InputStream is = ch.getInputStream();
|
InputStream is = ch.getInputStream();
|
||||||
OutputStream os = ch.getOutputStream();
|
OutputStream os = ch.getOutputStream();
|
||||||
ch.connect();
|
ch.connect();
|
||||||
|
@ -446,7 +439,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
String fileHeader = "C0644" + " " + localFile.length() + " " //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
|
String fileHeader = "C0644" + " " + localFile.length() + " " //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
|
||||||
+ remoteFile + "\n"; //$NON-NLS-1$
|
+ remoteFile + "\n"; //$NON-NLS-1$
|
||||||
if (readAck(is) != 0)
|
if (readAck(is) != 0)
|
||||||
throw new Exception("upload: wrong Ack! Last error:"
|
throw new Exception(SshServiceResources.ScpFileService_ReadAckError
|
||||||
+ getLastError());
|
+ getLastError());
|
||||||
|
|
||||||
os.write(fileHeader.getBytes());
|
os.write(fileHeader.getBytes());
|
||||||
|
@ -470,8 +463,8 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
os.write(buf, 0, 1);
|
os.write(buf, 0, 1);
|
||||||
os.flush();
|
os.flush();
|
||||||
if (readAck(is) != 0)
|
if (readAck(is) != 0)
|
||||||
throw new Exception("Error happened while uploading "
|
throw new Exception(NLS.bind(SshServiceResources.ScpFileService_UploadException
|
||||||
+ localFile.getAbsolutePath() + ":" + getLastError());
|
,localFile.getAbsolutePath(),getLastError()));
|
||||||
monitor.internalWorked(1);
|
monitor.internalWorked(1);
|
||||||
|
|
||||||
os.close();
|
os.close();
|
||||||
|
@ -487,7 +480,7 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
try {
|
try {
|
||||||
internalUpload(localFile, remotePath, remoteFile, monitor);
|
internalUpload(localFile, remotePath, remoteFile, monitor);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throwSystemException(e);
|
SshFileUtils.throwSystemException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -516,11 +509,11 @@ public class ScpFileService extends AbstractFileService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "SSH/SCP File Service can be used to connect to embedded sshd implementations, which often lacks sftp service";
|
return SshServiceResources.ScpFileService_Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "SCP File Service";
|
return SshServiceResources.ScpFileService_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -15,12 +15,13 @@
|
||||||
* Martin Oberhuber (Wind River) - Adapted from FTPRemoteFile.
|
* Martin Oberhuber (Wind River) - Adapted from FTPRemoteFile.
|
||||||
* Martin Oberhuber (Wind River) - [216343] immediate link targets and canonical paths for Sftp
|
* Martin Oberhuber (Wind River) - [216343] immediate link targets and canonical paths for Sftp
|
||||||
* Nikita Shulga (Mentor Graphics)- Adapted from SftpRemoteFile.
|
* Nikita Shulga (Mentor Graphics)- Adapted from SftpRemoteFile.
|
||||||
|
* Anna Dushistova (MontaVista) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.subsystems.files.scp;
|
package org.eclipse.rse.internal.subsystems.files.scp;
|
||||||
|
|
||||||
|
import org.eclipse.rse.internal.services.ssh.files.SshFileUtils;
|
||||||
import org.eclipse.rse.internal.services.ssh.files.SftpHostFile;
|
import org.eclipse.rse.internal.services.ssh.files.SftpHostFile;
|
||||||
import org.eclipse.rse.internal.services.ssh.files.scp.ScpFileUtils;
|
|
||||||
import org.eclipse.rse.services.files.IHostFile;
|
import org.eclipse.rse.services.files.IHostFile;
|
||||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.AbstractRemoteFile;
|
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.servicesubsystem.FileServiceSubSystem;
|
||||||
|
@ -44,8 +45,8 @@ public class ScpRemoteFile extends AbstractRemoteFile {
|
||||||
if (canonicalPath.equals(getAbsolutePath()) && _parentFile != null) {
|
if (canonicalPath.equals(getAbsolutePath()) && _parentFile != null) {
|
||||||
String parentCanonicalPath = _parentFile.getCanonicalPath();
|
String parentCanonicalPath = _parentFile.getCanonicalPath();
|
||||||
StringBuffer path = new StringBuffer(parentCanonicalPath);
|
StringBuffer path = new StringBuffer(parentCanonicalPath);
|
||||||
if (!parentCanonicalPath.endsWith(ScpFileUtils.TARGET_SEPARATOR))
|
if (!parentCanonicalPath.endsWith(SshFileUtils.TARGET_SEPARATOR))
|
||||||
path.append(ScpFileUtils.TARGET_SEPARATOR);
|
path.append(SshFileUtils.TARGET_SEPARATOR);
|
||||||
|
|
||||||
path.append(getName());
|
path.append(getName());
|
||||||
canonicalPath = path.toString();
|
canonicalPath = path.toString();
|
||||||
|
|
Loading…
Add table
Reference in a new issue