1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for PR 38468: Error in files location.

Use the 'getCanonicalPath' method of the 'File' class to obtain the file name.
This commit is contained in:
Mikhail Khodjaiants 2003-09-16 18:40:02 +00:00
parent 5deee229dd
commit 93129aabdc
4 changed files with 60 additions and 18 deletions

View file

@ -1,3 +1,10 @@
2003-16-10 Mikhail Khodjaiants
Fix for PR 38468: Error in files location.
Use the 'getCanonicalPath' method of the 'File' class to obtain the file name.
* CDirectorySourceLocation.java
* CProjectSourceLocation.java
* CSourceLocator.java
2003-15-10 Mikhail Khodjaiants
Fix for PR 43101: Breakpoint exception when source doesn't exist.
The 'fireBreakpointChanged' method of 'BreakpointManager' is used to notify

View file

@ -145,8 +145,20 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
return fAssociation;
}
private Object findFileByAbsolutePath( String fileName )
private Object findFileByAbsolutePath( String name )
{
File file = new File( name );
if ( !file.isAbsolute() )
return null;
String fileName;
try
{
fileName = file.getCanonicalPath();
}
catch( IOException e )
{
return null;
}
IPath filePath = new Path( fileName );
IPath path = getDirectory();
IPath association = getAssociation();
@ -169,7 +181,7 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
return f;
}
File file = filePath.toFile();
file = filePath.toFile();
if ( file.exists() )
{
return createExternalFileStorage( filePath );
@ -186,12 +198,19 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
File file = path.toFile();
if ( file.exists() )
{
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
if ( f != null )
try
{
return f;
}
return createExternalFileStorage( path );
path = new Path( file.getCanonicalPath() );
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
if ( f != null )
{
return f;
}
return createExternalFileStorage( path );
}
catch( IOException e )
{
}
}
}
return null;

View file

@ -30,7 +30,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -153,8 +152,17 @@ public class CProjectSourceLocation implements IProjectSourceLocation
private Object findFileByAbsolutePath( String name )
{
IPath path = new Path( name );
return findFile( getProject(), path.toOSString() );
File file = new File( name );
Object result = null;
try
{
if ( file.isAbsolute() )
result = findFile( getProject(), file.getCanonicalPath() );
}
catch( IOException e )
{
}
return result;
}
private Object findFileByRelativePath( IContainer container, String fileName )

View file

@ -6,6 +6,7 @@
package org.eclipse.cdt.debug.internal.core.sourcelookup;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.text.MessageFormat;
@ -249,16 +250,23 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
private Object findFileByAbsolutePath( String fileName )
{
Path path = new Path( fileName );
if ( path.isAbsolute() && path.toFile().exists() )
File file = new File( fileName );
if ( file.isAbsolute() && file.exists() )
{
// Try for a file in another workspace project
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
if ( f != null && f.exists() )
try
{
return f;
}
return new FileStorage( path );
Path path = new Path( file.getCanonicalPath() );
// Try for a file in another workspace project
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
if ( f != null && f.exists() )
{
return f;
}
return new FileStorage( path );
}
catch( IOException e )
{
}
}
return null;
}