Skip to content

Commit

Permalink
server: Bug 581174: Fix path handling for traces when running on Windows
Browse files Browse the repository at this point in the history
When the trace server is started on Windows where the CWD
is a lower case drive letter the device handling code in
Eclipse does not work. The root cause of this is we
were making a Posix o.e.c.runtime.Path on Windows so the
c: was being identified as a path segment rather than
a device.

[Fixed] Fix path handling for traces when running server on Windows

Change-Id: Ife4f1ddd9786e298f6afd088f366d4dc148caa2d
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/197483
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
  • Loading branch information
jonahgraham authored and bhufmann committed Dec 7, 2022
1 parent c070ca2 commit d49611b
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private static IResource getResource(String path, String name) throws CoreExcept
*/
private static synchronized boolean createResource(String path, IResource resource) throws CoreException {
// create the resource hierarchy.
IPath targetLocation = org.eclipse.core.runtime.Path.forPosix(path);
IPath targetLocation = new org.eclipse.core.runtime.Path(path);
createFolder((IFolder) resource.getParent(), null);
if (!ResourceUtil.createSymbolicLink(resource, targetLocation, true, null)) {
return false;
Expand Down Expand Up @@ -454,11 +454,21 @@ public static void dispose() {
TRACES.clear();
}

/**
* Get the location in the workspace that will represent this path on disk.
*
* @param path
* The full path to the trace on disk
* @return The path in the workspace where the trace is represented
*/
private static IPath getTargetLocation(String path) {
if (IS_WINDOWS) {
IPath p = org.eclipse.core.runtime.Path.forWindows(path);
return new org.eclipse.core.runtime.Path(p.toString().replace(":", "")).removeTrailingSeparator(); //$NON-NLS-1$ //$NON-NLS-2$
IPath p = new org.eclipse.core.runtime.Path(path);
if (p.getDevice() != null) {
// We need to make a path that is a valid file/folder location within the Eclipse
// workspace, this means if there is a device involved we need to drop the :
// or else later we'll fail to make the path
p = new org.eclipse.core.runtime.Path(p.toString().replace(":", "")); //$NON-NLS-1$ //$NON-NLS-2$
}
return org.eclipse.core.runtime.Path.forPosix(path).removeTrailingSeparator();
return p.removeTrailingSeparator();
}
}

0 comments on commit d49611b

Please sign in to comment.