mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 226453: NPE in CygpathTranslator if no Cygwin installed
This commit is contained in:
parent
68db07fc5d
commit
02686bc022
1 changed files with 18 additions and 17 deletions
|
@ -84,12 +84,12 @@ public class CygpathTranslator {
|
|||
* @param sumIncludes
|
||||
* @return
|
||||
*/
|
||||
public static List translateIncludePaths(IProject project, List sumIncludes) {
|
||||
public static List<String> translateIncludePaths(IProject project, List<String> sumIncludes) {
|
||||
// first check if cygpath translation is needed at all
|
||||
boolean translationNeeded = false;
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String include = (String) i.next();
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String include = i.next();
|
||||
if (include.startsWith("/")) { //$NON-NLS-1$
|
||||
translationNeeded = true;
|
||||
break;
|
||||
|
@ -102,9 +102,9 @@ public class CygpathTranslator {
|
|||
|
||||
CygpathTranslator cygpath = new CygpathTranslator(project);
|
||||
|
||||
List translatedIncludePaths = new ArrayList();
|
||||
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String includePath = (String) i.next();
|
||||
List<String> translatedIncludePaths = new ArrayList<String>();
|
||||
for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||
String includePath = i.next();
|
||||
IPath realPath = new Path(includePath);
|
||||
// only allow native pathes if they have a device prefix
|
||||
// to avoid matches on the current drive, e.g. /usr/bin = C:\\usr\\bin
|
||||
|
@ -123,26 +123,25 @@ public class CygpathTranslator {
|
|||
} else if (realPath.segmentCount() >= 2) {
|
||||
// try default conversions
|
||||
// /cygdrive/x/ --> X:\
|
||||
// /usr/ --> C:\Cygwin\\usr\\
|
||||
if ("cygdrive".equals(realPath.segment(0))) { //$NON-NLS-1$
|
||||
String drive= realPath.segment(1);
|
||||
if (drive.length() == 1) {
|
||||
translatedPath= realPath.removeFirstSegments(2).setDevice(drive.toUpperCase() + ':').toOSString();
|
||||
}
|
||||
} else {
|
||||
translatedPath= DEFAULT_CYGWIN_ROOT + realPath.toOSString();
|
||||
}
|
||||
}
|
||||
if (!translatedPath.equals(includePath)) {
|
||||
// Check if the translated path exists
|
||||
IPath transPath = new Path(translatedPath);
|
||||
if (transPath.toFile().exists()) {
|
||||
translatedIncludePaths.add(transPath.toPortableString());
|
||||
if (new File(translatedPath).exists()) {
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else {
|
||||
else if (cygpath.isAvailable) {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
translatedIncludePaths.add(translatedPath);
|
||||
}
|
||||
else {
|
||||
translatedIncludePaths.add(includePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO VMIR for now add even if it does not exist
|
||||
|
@ -150,7 +149,9 @@ public class CygpathTranslator {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (cygpath.cygPath != null) {
|
||||
cygpath.cygPath.dispose();
|
||||
}
|
||||
return translatedIncludePaths;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue