Fix CopyToContainer on Windows
- when copying to Container on Windows, we must massage the target path to change the
file separator from backslash to forward slash
Change-Id: I11cbac252ef48843b8ca3e62248cf20870125a1f
Reviewed-on: https://git.eclipse.org/r/c/linuxtools/org.eclipse.linuxtools/+/173174
Tested-by: Linux Tools Bot <linuxtools-bot@eclipse.org>
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index 26a159c..7d8862a 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -44,6 +44,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -2055,7 +2056,9 @@
DockerClient copy = (DockerClient) token;
java.nio.file.Path dirPath = FileSystems.getDefault()
.getPath(directory);
- copy.copyToContainer(dirPath, id, path);
+ boolean isWin = Platform.getOS().equals(Platform.OS_WIN32);
+ copy.copyToContainer(dirPath, id,
+ isWin ? path.replace('\\', '/') : path);
copy.close(); /* dispose of client copy now that we are done */
} catch (org.mandas.docker.client.exceptions.DockerException e) {
throw new DockerException(e.getMessage(), e.getCause());