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,34 +74,32 @@ public class MapEntrySourceContainer extends AbstractSourceContainer {
|
|||
public static IPath createPath(String path) {
|
||||
if (path == null)
|
||||
return null;
|
||||
if (path.contains("\\")) { //$NON-NLS-1$
|
||||
// handle Windows slashes and canonicalize
|
||||
path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
// also check for device or UNC
|
||||
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
|
||||
if (path.startsWith("//")) { //$NON-NLS-1$
|
||||
String network;
|
||||
idx = path.indexOf("/", 2); //$NON-NLS-1$
|
||||
if (idx > 0) {
|
||||
network = path.substring(0, idx);
|
||||
path = path.substring(idx);
|
||||
} else {
|
||||
network = path;
|
||||
path = ""; //$NON-NLS-1$
|
||||
}
|
||||
return new Path(network, path).makeUNC(true);
|
||||
|
||||
// Check for windows full-path formatting.
|
||||
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);
|
||||
}
|
||||
|
||||
int idx = 0;
|
||||
// Cygwin or UNC path
|
||||
if (path.startsWith("//")) { //$NON-NLS-1$
|
||||
String network;
|
||||
idx = path.indexOf("/", 2); //$NON-NLS-1$
|
||||
if (idx > 0) {
|
||||
network = path.substring(0, idx);
|
||||
path = path.substring(idx);
|
||||
} else {
|
||||
network = path;
|
||||
path = ""; //$NON-NLS-1$
|
||||
}
|
||||
return new Path(network, path).makeUNC(true);
|
||||
}
|
||||
|
||||
// fallthrough
|
||||
|
|
|
@ -37,7 +37,7 @@ public class MapEntrySourceContainerType extends AbstractSourceContainerTypeDele
|
|||
Element element = (Element)node;
|
||||
if (ELEMENT_NAME.equals(element.getNodeName())) {
|
||||
String path = element.getAttribute(BACKEND_PATH);
|
||||
IPath backend = new Path(path);
|
||||
IPath backend = MapEntrySourceContainer.createPath(path);
|
||||
if (!backend.isValidPath(path)) {
|
||||
abort(InternalSourceLookupMessages.MapEntrySourceContainerType_0, null);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue