diff --git a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java index 1ceb63785f6..53672d96f42 100644 --- a/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java +++ b/bundles/org.eclipse.equinox.common.tests/src/org/eclipse/equinox/common/tests/PathTest.java @@ -317,6 +317,18 @@ public void testConstructors() { assertEquals("3.0.win", "D:/foo/abc.txt", IPath.forWindows("/D:/foo/abc.txt").toString()); // fullPath = new java.io.File("D:/").toURL().getPath() assertEquals("3.1.win", "D:/", IPath.forWindows("/D:/").toString()); + + final String verylongpath = "C:/dev/verylongpath/00112233445566778899aabbccddeeff/00112233445566778899aabbccddeeff/00112233445566778899aabbccddeeff/" + + "00112233445566778899aabbccddeeff/00112233445566778899aabbccddeeff/00112233445566778899aabbccddeeff/root/lib/gcc/arm-none-eabi/7.3.1/include-fixed"; + anyPath = IPath.forWindows(verylongpath); + assertEquals("3.2.1.win", "C:", anyPath.getDevice()); + assertEquals("3.3.2.win", "dev", anyPath.segment(0)); + assertEquals("3.2.3.win", verylongpath, anyPath.toString()); + + anyPath = IPath.forWindows("//?/" + verylongpath); + assertEquals("3.3.1.win", "C:", anyPath.getDevice()); + assertEquals("3.3.2.win", "dev", anyPath.segment(0)); + assertEquals("3.3.3.win", verylongpath, anyPath.toString()); } public void testFactoryMethods() { diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF index 3e037b821bb..7815cc29c93 100644 --- a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.common; singleton:=true -Bundle-Version: 3.18.100.qualifier +Bundle-Version: 3.18.200.qualifier Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.boot;x-friends:="org.eclipse.core.resources,org.eclipse.pde.build", org.eclipse.core.internal.runtime;common=split;mandatory:=common; diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java index 8cf03c6b30c..87976929de9 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java @@ -302,8 +302,15 @@ private static String backslashToForward(String path, boolean forWindows) { //extract device int i = fullPath.indexOf(DEVICE_SEPARATOR); if (i != -1) { - //remove leading slash from device part to handle output of URL.getFile() - int start = fullPath.charAt(0) == SEPARATOR ? 1 : 0; + int start = 0; + if (fullPath.startsWith("//?/")) { //$NON-NLS-1$ + // Paths prefixed with "//?/" are local paths. For details: + // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces + start = 4; + } else if (fullPath.charAt(0) == SEPARATOR) { + // remove leading slash from device part to handle output of URL.getFile() + start = 1; + } devicePart = fullPath.substring(start, i + 1); fullPath = fullPath.substring(i + 1, fullPath.length()); }