Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Torregrosa Paez2016-03-23 15:41:55 +0000
committerPablo Torregrosa Paez2016-03-23 15:55:40 +0000
commit72051f1b5bd8fd3777bd2573dd13c8393e3bc02f (patch)
treecf4b5c6b50fb338d0b4da855a5d9e54bfaeda54c
parenta09b054d4acfd5ea7d09f1a2da9fdae525a5cdff (diff)
downloadorg.eclipse.tcf-72051f1b5bd8fd3777bd2573dd13c8393e3bc02f.tar.gz
org.eclipse.tcf-72051f1b5bd8fd3777bd2573dd13c8393e3bc02f.tar.xz
org.eclipse.tcf-72051f1b5bd8fd3777bd2573dd13c8393e3bc02f.zip
Target Explorer: Fix file download error when name contains spaces
Change-Id: I0e2e0429b0f1c9c2310a43e63e7c1c9ba94f047e Signed-off-by: Pablo Torregrosa Paez <pablo.torregrosa@windriver.com>
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java33
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java2
2 files changed, 31 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java
index 850bf534c..d1c7829c9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/FSTreeNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2015 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2016 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
@@ -289,8 +289,22 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org
*/
@Override
public URL getLocationURL() {
+ return getLocationURL(true);
+ }
+
+ /**
+ * Get the URL of the file or folder. The URL's format is created in the
+ * following way: tcf:/<peerName>/remote/path/to/the/resource... See
+ * {@link TcfURLConnection#TcfURLConnection(URL)}
+ * @param encodeName whether or not the URL has to be encoded.
+ *
+ * @see TcfURLStreamHandlerService#parseURL(URL, String, int, int)
+ * @see #getLocationURI()
+ * @return The URL of the file/folder.
+ */
+ public URL getLocationURL(boolean encodeName) {
try {
- URI uri = getLocationURI();
+ URI uri = getLocationURI(encodeName);
return uri == null ? null : uri.toURL();
} catch (MalformedURLException e) {
CorePlugin.logError("Cannot create tcf url", e); //$NON-NLS-1$
@@ -298,6 +312,8 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org
return null;
}
+
+
/**
* Get the URI of the file or folder. The URI's format is created in the
* following way: tcf:/<peerName>/remote/path/to/the/resource...
@@ -306,9 +322,20 @@ public final class FSTreeNode extends FSTreeNodeBase implements IFilterable, org
*/
@Override
public URI getLocationURI() {
+ return getLocationURI(true);
+ }
+
+ /**
+ * Get the URI of the file or folder. The URI's format is created in the
+ * following way: tcf:/<peerName>/remote/path/to/the/resource...
+ * @param encodeName whether or not the URL has to be encoded.
+ *
+ * @return The URI of the file/folder.
+ */
+ public URI getLocationURI(boolean encodeName) {
try {
String name = getPeerNode().getName();
- String path = getLocation('/', true);
+ String path = getLocation('/', encodeName);
return new URI(TcfURLConnection.PROTOCOL_SCHEMA, name, addNoSlashMarker(path), null, null);
} catch (URISyntaxException e) {
CorePlugin.logError("Cannot create tcf uri", e); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
index d638ce5ed..1926cd7d4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/OpDownload.java
@@ -86,7 +86,7 @@ public class OpDownload extends AbstractOperation {
BufferedInputStream input = null;
- TcfURLConnection connection = (TcfURLConnection) source.getLocationURL().openConnection();
+ TcfURLConnection connection = (TcfURLConnection) source.getLocationURL(false).openConnection();
try {
if (digest != null) {
input = new BufferedInputStream(new DigestInputStream(connection.getInputStream(), digest));

Back to the top