mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 393791 - Cannot substitute Windows path to Unix path on Linux
This commit is contained in:
parent
b004558b81
commit
da9df79e53
2 changed files with 26 additions and 28 deletions
|
@ -74,21 +74,20 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
|
||||||
public static IPath createPath(String path) {
|
public static IPath createPath(String path) {
|
||||||
if (path == null)
|
if (path == null)
|
||||||
return null;
|
return null;
|
||||||
if (path.contains("\\")) { //$NON-NLS-1$
|
|
||||||
// handle Windows slashes and canonicalize
|
// Check for windows full-path formatting.
|
||||||
path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
if (path.matches("^([a-zA-Z])[:](.*)$")) { //$NON-NLS-1$
|
||||||
|
String device = null;
|
||||||
|
String missingfile = path.replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
int idx = missingfile.indexOf(":"); //$NON-NLS-1$
|
||||||
|
if ( idx > 0 ) {
|
||||||
|
device = missingfile.substring(0, idx + 1);
|
||||||
|
missingfile = missingfile.substring(idx + 1);
|
||||||
|
}
|
||||||
|
return new Path(device, missingfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// also check for device or UNC
|
int idx = 0;
|
||||||
int firstSep = path.indexOf("/"); //$NON-NLS-1$
|
|
||||||
int idx = path.indexOf(":"); //$NON-NLS-1$
|
|
||||||
// ':' indicates a Windows device separator if it comes before
|
|
||||||
// the first segment separator
|
|
||||||
if (idx > 0 && (firstSep < 0 || idx < firstSep)) {
|
|
||||||
String device = path.substring(0, idx + 1);
|
|
||||||
path = path.substring(idx + 1);
|
|
||||||
return new Path(path).setDevice(device);
|
|
||||||
} else {
|
|
||||||
// Cygwin or UNC path
|
// Cygwin or UNC path
|
||||||
if (path.startsWith("//")) { //$NON-NLS-1$
|
if (path.startsWith("//")) { //$NON-NLS-1$
|
||||||
String network;
|
String network;
|
||||||
|
@ -102,7 +101,6 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
|
||||||
}
|
}
|
||||||
return new Path(network, path).makeUNC(true);
|
return new Path(network, path).makeUNC(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// fallthrough
|
// fallthrough
|
||||||
return new Path(path);
|
return new Path(path);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class MapEntrySourceContainerType extends AbstractSourceContainerTypeDele
|
||||||
Element element = (Element)node;
|
Element element = (Element)node;
|
||||||
if (ELEMENT_NAME.equals(element.getNodeName())) {
|
if (ELEMENT_NAME.equals(element.getNodeName())) {
|
||||||
String path = element.getAttribute(BACKEND_PATH);
|
String path = element.getAttribute(BACKEND_PATH);
|
||||||
IPath backend = new Path(path);
|
IPath backend = MapEntrySourceContainer.createPath(path);
|
||||||
if (!backend.isValidPath(path)) {
|
if (!backend.isValidPath(path)) {
|
||||||
abort(InternalSourceLookupMessages.MapEntrySourceContainerType_0, null);
|
abort(InternalSourceLookupMessages.MapEntrySourceContainerType_0, null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue