1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

[297781] Executables view accidentally converting UNIX paths to windows c: based ones (on Windows)

This commit is contained in:
John Cortell 2009-12-14 22:59:38 +00:00
parent 6e9b99adf9
commit bbf22bce99

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.core.executables;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -135,7 +136,7 @@ public class Executable extends PlatformObject {
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
* @since 6.0 * @since 6.0
*/ */
public TranslationUnit[] getSourceFiles(IProgressMonitor monitor) { public ITranslationUnit[] getSourceFiles(IProgressMonitor monitor) {
if (!refreshSourceFiles) if (!refreshSourceFiles)
return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ; return sourceFiles.toArray(new TranslationUnit[sourceFiles.size()]) ;
@ -153,26 +154,18 @@ public class Executable extends PlatformObject {
String[] symReaderSources = ExecutablesManager.getExecutablesManager().getSourceFiles(this, monitor); String[] symReaderSources = ExecutablesManager.getExecutablesManager().getSourceFiles(this, monitor);
if (symReaderSources != null && symReaderSources.length > 0) { if (symReaderSources != null && symReaderSources.length > 0) {
for (int i = 0; i < symReaderSources.length; i++) { for (String filename : symReaderSources) {
String filename = symReaderSources[i];
String orgPath = filename; String orgPath = filename;
filename = ExecutablesManager.getExecutablesManager().remapSourceFile(this, filename); filename = ExecutablesManager.getExecutablesManager().remapSourceFile(this, filename);
// Sometimes the path in the symbolics will have a // Sometimes the path in the symbolics will have a different
// different // case than the actual file system path. Even if the file
// case than the actual file system path. Even if the // system is not case sensitive this will confuse the Path
// file // class. So make sure the path is canonical, otherwise
// system is not case sensitive this will confuse the // breakpoints won't be resolved, etc.. Also check for relative
// Path // path names and attempt to resolve them relative to the
// class. // executable.
// So make sure the path is canonical, otherwise
// breakpoints
// won't be resolved, etc..
// Also check for relative path names and attempt to
// resolve
// them relative to the executable.
boolean fileExists = false; boolean fileExists = false;
try { try {
@ -198,11 +191,10 @@ public class Executable extends PlatformObject {
if (sourceFile.exists()) if (sourceFile.exists())
wkspFile = sourceFile; wkspFile = sourceFile;
else { else {
IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(sourcePath); IFile[] filesInWP = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(URIUtil.toURI(sourcePath));
for (IFile fileInWP : filesInWP) {
for (int j = 0; j < filesInWP.length; j++) { if (fileInWP.isAccessible()) {
if (filesInWP[j].isAccessible()) { wkspFile = fileInWP;
wkspFile = filesInWP[j];
break; break;
} }
} }
@ -218,8 +210,14 @@ public class Executable extends PlatformObject {
TranslationUnit tu; TranslationUnit tu;
if (wkspFile != null) if (wkspFile != null)
tu = new TranslationUnit(cproject, wkspFile, id); tu = new TranslationUnit(cproject, wkspFile, id);
else else {
tu = new ExternalTranslationUnit(cproject, URIUtil.toURI(sourcePath), id); // Be careful not to convert a unix path like
// "/src/home" to "c:\source\home" on Windows. See
// bugzilla 297781
URI uri = (sourcePath.toFile().exists()) ? URIUtil.toURI(sourcePath) : URIUtil.toURI(filename);
tu = new ExternalTranslationUnit(cproject, uri, id);
}
sourceFiles.add(tu); sourceFiles.add(tu);