mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-12 03:25:22 +02:00
[331213] refactored the files.scp plugin.
This commit is contained in:
parent
e61c37f193
commit
56627d09a0
16 changed files with 70 additions and 53 deletions
|
@ -12,7 +12,7 @@
|
|||
<feature
|
||||
id="org.eclipse.rse.ssh"
|
||||
label="%featureName"
|
||||
version="3.0.200.qualifier"
|
||||
version="3.0.300.qualifier"
|
||||
provider-name="%providerName"
|
||||
plugin="org.eclipse.rse.services.ssh">
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<feature
|
||||
id="org.eclipse.rse.terminals"
|
||||
label="%featureName"
|
||||
version="1.0.101.qualifier"
|
||||
version="1.0.200.qualifier"
|
||||
provider-name="%providerName"
|
||||
plugin="org.eclipse.rse.terminals.ui"
|
||||
image="eclipse_update_120.jpg">
|
||||
|
|
|
@ -2,12 +2,12 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.connectorservice.ssh; singleton:=true
|
||||
Bundle-Version: 2.1.100.qualifier
|
||||
Bundle-Version: 2.1.200.qualifier
|
||||
Bundle-Activator: org.eclipse.rse.internal.connectorservice.ssh.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.services.ssh;singleton:=true
|
||||
Bundle-Version: 3.0.100.qualifier
|
||||
Bundle-Version: 3.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.rse.internal.services.ssh.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -13,5 +13,6 @@ Bundle-ActivationPolicy: lazy
|
|||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.internal.services.ssh;x-friends:="org.eclipse.rse.connectorservice.ssh,org.eclipse.rse.subsystems.files.ssh,org.eclipse.rse.subsystems.shells.ssh",
|
||||
org.eclipse.rse.internal.services.ssh.files;x-friends:="org.eclipse.rse.connectorservice.ssh,org.eclipse.rse.subsystems.files.ssh,org.eclipse.rse.subsystems.shells.ssh",
|
||||
org.eclipse.rse.internal.services.ssh.terminal;x-friends:="org.eclipse.rse.subsystems.shells.ssh"
|
||||
org.eclipse.rse.internal.services.ssh.terminal;x-friends:="org.eclipse.rse.subsystems.shells.ssh",
|
||||
org.eclipse.rse.internal.services.ssh.files.scp;x-friends:="org.eclipse.rse.subsystems.files.scp"
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* Anna Dushistova (Mentor Graphics) - [331213][scp] Provide UI-less scp IFileService in org.eclipse.rse.services.ssh
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh;
|
||||
|
@ -116,4 +117,21 @@ public class Activator extends Plugin {
|
|||
|
||||
//</tracing code>---------------------------------------------------
|
||||
|
||||
public static void log(String msg) {
|
||||
log(msg, null);
|
||||
}
|
||||
|
||||
public static void log(String msg, Exception e) {
|
||||
log(IStatus.INFO, msg, e);
|
||||
}
|
||||
|
||||
public static void warn(String msg, Exception e) {
|
||||
log(IStatus.WARNING, msg, e);
|
||||
}
|
||||
|
||||
public static void log(int sev, String msg, Exception e) {
|
||||
Platform.getLog(getDefault().getBundle()).log(
|
||||
new Status(sev, PLUGIN_ID, msg, e));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.files.scp;
|
||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -19,6 +20,7 @@ import java.util.Date;
|
|||
import java.util.Stack;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.rse.internal.services.ssh.Activator;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.files.HostFilePermissions;
|
||||
import org.eclipse.rse.services.files.IHostFilePermissions;
|
||||
|
@ -186,33 +188,34 @@ public class ScpFileAttr {
|
|||
private static Pattern lsPattern = Pattern.compile("\\s+"); //$NON-NLS-1$
|
||||
|
||||
public void SplitAux() throws Exception {
|
||||
Stack<String> fields = new Stack<String>();
|
||||
for (String s : lsPattern.split(lsString))
|
||||
fields.insertElementAt(s, 0);
|
||||
Stack fields = new Stack();
|
||||
String[] lsPatterns = lsPattern.split(lsString);
|
||||
for (int i=0;i<lsPatterns.length;i++)
|
||||
fields.insertElementAt(lsPatterns[i], 0);
|
||||
|
||||
/* store file attributes */
|
||||
if (fields.empty())
|
||||
return;
|
||||
attrString = fields.pop();
|
||||
attrString = (String) fields.pop();
|
||||
|
||||
/* store link number */
|
||||
if (fields.empty())
|
||||
return;
|
||||
linkNo = Integer.parseInt(fields.pop());
|
||||
linkNo = Integer.parseInt((String) fields.pop());
|
||||
|
||||
/* store uid and gid */
|
||||
if (fields.empty())
|
||||
return;
|
||||
user = fields.pop();
|
||||
user = (String) fields.pop();
|
||||
if (fields.empty())
|
||||
return;
|
||||
group = fields.pop();
|
||||
group = (String) fields.pop();
|
||||
|
||||
/* store file size */
|
||||
if (fields.empty())
|
||||
return;
|
||||
if (!isCharDevice() && !isBlockDevice())
|
||||
size = Long.parseLong(fields.pop());
|
||||
size = Long.parseLong((String) fields.pop());
|
||||
else {
|
||||
/* Size is undefined for character and block devices */
|
||||
size = 0;
|
||||
|
@ -226,7 +229,7 @@ public class ScpFileAttr {
|
|||
/* Short date formats always take three fields, long(iso) date format takes only two */
|
||||
if (fields.empty())
|
||||
return;
|
||||
String dateField = fields.pop();
|
||||
String dateField = (String) fields.pop();
|
||||
if (fields.empty())
|
||||
return;
|
||||
dateField = dateField + " " + fields.pop(); //$NON-NLS-1$
|
|
@ -6,9 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.subsystems.files.scp;
|
||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -21,6 +22,8 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
import org.eclipse.rse.internal.services.ssh.Activator;
|
||||
import org.eclipse.rse.internal.services.ssh.ISshSessionProvider;
|
||||
import org.eclipse.rse.internal.services.ssh.files.SftpHostFile;
|
||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||
|
@ -38,7 +41,6 @@ import org.eclipse.rse.services.files.IHostFilePermissionsContainer;
|
|||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class ScpFileService extends AbstractFileService implements
|
||||
IFilePermissionsService {
|
||||
|
||||
|
@ -73,13 +75,12 @@ public class ScpFileService extends AbstractFileService implements
|
|||
Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IHostFile[] internalFetch(String parentPath, String fileFilter,
|
||||
int fileType, IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
|
||||
if (fileFilter == null)
|
||||
fileFilter = "*";
|
||||
fileFilter = "*"; //$NON-NLS-1$
|
||||
IMatcher filematcher = null;
|
||||
if (fileFilter.endsWith(",")) { //$NON-NLS-1$
|
||||
String[] types = fileFilter.split(","); //$NON-NLS-1$
|
||||
|
@ -88,19 +89,19 @@ public class ScpFileService extends AbstractFileService implements
|
|||
filematcher = new NamePatternMatcher(fileFilter, true, true);
|
||||
}
|
||||
|
||||
List<IHostFile> results = new ArrayList<IHostFile>();
|
||||
List results = new ArrayList();
|
||||
Session sess = getSession();
|
||||
String cmd = "ls -lAn " + ScpFileUtils.escapePath(parentPath); //$NON-NLS-1$
|
||||
|
||||
String rc = ScpFileUtils.execCommandSafe(sess, cmd);
|
||||
|
||||
for (String lsString : rc.split(ScpFileUtils.EOL_STRING)) {
|
||||
if (lsString.length() == 0 || lsString.startsWith("total")) //$NON-NLS-1$
|
||||
String[] lsStrings = rc.split(ScpFileUtils.EOL_STRING);
|
||||
for (int i=0;i<lsStrings.length;i++){
|
||||
if (lsStrings[i].length() == 0 || lsStrings[i].startsWith("total")) //$NON-NLS-1$
|
||||
continue;
|
||||
ScpFileAttr attr = new ScpFileAttr(lsString);
|
||||
ScpFileAttr attr = new ScpFileAttr(lsStrings[i]);
|
||||
if (attr == null || attr.getName() == null) {
|
||||
Activator.warn("internalFetch(parentPath='" + parentPath
|
||||
+ "'): Can't get name of " + lsString, null);
|
||||
+ "'): Can't get name of " + lsStrings[i], null);
|
||||
continue;
|
||||
}
|
||||
if (!filematcher.matches(attr.getName()))
|
||||
|
@ -509,12 +510,10 @@ public class ScpFileService extends AbstractFileService implements
|
|||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "SSH/SCP File Service can be used to connect to embedded sshd implementations, which often lacks sftp service";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SCP File Service";
|
||||
}
|
|
@ -6,10 +6,11 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.files.scp;
|
||||
package org.eclipse.rse.internal.services.ssh.files.scp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
|
@ -7,7 +7,7 @@ Bundle-Vendor: %providerName
|
|||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Require-Bundle: org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.1.0,4.0.0)",
|
||||
org.eclipse.rse.connectorservice.ssh;bundle-version="[2.0.0,2.2.0)",
|
||||
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.eclipse.rse.internal.subsystems.files.scp;
|
||||
|
||||
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.subsystems.files.core.servicesubsystem.AbstractRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
|
|||
import org.eclipse.rse.internal.connectorservice.ssh.SshConnectorService;
|
||||
import org.eclipse.rse.internal.connectorservice.ssh.SshConnectorServiceManager;
|
||||
import org.eclipse.rse.internal.services.ssh.ISshService;
|
||||
import org.eclipse.rse.internal.services.ssh.files.scp.ScpFileService;
|
||||
import org.eclipse.rse.internal.subsystems.files.scp.ScpFileAdapter;
|
||||
import org.eclipse.rse.internal.subsystems.files.scp.ScpFileService;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.SystemSearchString;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.subsystems.files.ssh; singleton:=true
|
||||
Bundle-Version: 2.1.100.qualifier
|
||||
Bundle-Version: 2.1.200.qualifier
|
||||
Bundle-Activator: org.eclipse.rse.internal.subsystems.files.ssh.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.connectorservice.ssh;bundle-version="[2.1.0,3.0.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)"
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.subsystems.shells.ssh; singleton:=true
|
||||
Bundle-Version: 2.1.100.qualifier
|
||||
Bundle-Version: 2.1.200.qualifier
|
||||
Bundle-Activator: org.eclipse.rse.internal.subsystems.shells.ssh.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services;bundle-version="[3.1.0,4.0.0)",
|
||||
org.eclipse.rse.connectorservice.ssh;bundle-version="[2.1.0,3.0.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
|
||||
|
|
|
@ -2,12 +2,12 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.subsystems.terminals.ssh;singleton:=true
|
||||
Bundle-Version: 1.0.1.qualifier
|
||||
Bundle-Version: 1.0.100.qualifier
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services;bundle-version="[3.1.0,4.0.0)",
|
||||
org.eclipse.rse.connectorservice.ssh;bundle-version="[2.1.0,3.0.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.subsystems.terminals.core;bundle-version="[1.0.0,2.0.0)",
|
||||
org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
<!--
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
|
@ -8,11 +9,10 @@
|
|||
Contributors:
|
||||
IBM Corporation - initial API and implementation
|
||||
-->
|
||||
|
||||
<feature
|
||||
id="org.eclipse.rse.tests"
|
||||
label="%featureName"
|
||||
version="3.2.0.qualifier"
|
||||
version="3.3.0.qualifier"
|
||||
provider-name="%providerName">
|
||||
|
||||
<description>
|
||||
|
@ -47,12 +47,6 @@
|
|||
<import plugin="org.eclipse.rse.subsystems.files.ftp" version="2.1.0" match="compatible"/>
|
||||
<import plugin="org.eclipse.jface.text"/>
|
||||
<import plugin="org.eclipse.help"/>
|
||||
<!-- org.junit either comes with the JDT feature (org.eclipse.jdt), -->
|
||||
<!-- or with the eclipse-test-framework download. So, don't put a -->
|
||||
<!-- feature dependency here since it is no hard dependency -->
|
||||
<!-- (although it would help Europa users to get their stuff, but -->
|
||||
<!-- it could invalidate the configuration for Platform users: -->
|
||||
<!-- bug 151797) -->
|
||||
<import plugin="org.junit" version="3.8.1" match="compatible"/>
|
||||
<import plugin="org.apache.ant"/>
|
||||
</requires>
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.rse.tests;singleton:=true
|
||||
Bundle-Version: 3.2.0.qualifier
|
||||
Bundle-Version: 3.3.0.qualifier
|
||||
Bundle-Activator: org.eclipse.rse.tests.RSETestsPlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
@ -21,7 +21,7 @@ Require-Bundle: org.junit,
|
|||
org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.services;bundle-version="[3.1.0,4.0.0)",
|
||||
org.eclipse.rse.services.files.ftp;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,3.1.0)",
|
||||
org.eclipse.rse.services.ssh;bundle-version="[3.0.0,4.0.0)",
|
||||
org.eclipse.rse.subsystems.files.ftp;bundle-version="[2.1.0,3.0.0)",
|
||||
org.eclipse.rse.importexport;bundle-version="[1.2.0,1.3.0)",
|
||||
org.eclipse.rse.files.ui,
|
||||
|
|
Loading…
Add table
Reference in a new issue