Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for PR 38468: Error in files location

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.250
diff -u -r1.250 ChangeLog
--- ChangeLog 15 Sep 2003 18:33:15 -0000 1.250
+++ ChangeLog 16 Sep 2003 18:38:51 -0000
@@ -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
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java,v
retrieving revision 1.10
diff -u -r1.10 CDirectorySourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 28 Jul 2003 19:40:22 -0000 1.10
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 16 Sep 2003 18:38:54 -0000
@@ -145,8 +145,20 @@
   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 @@
    return f;
   }
 
-  File file = filePath.toFile();
+  file = filePath.toFile();
   if ( file.exists() )
   {
    return createExternalFileStorage( filePath );
@@ -186,12 +198,19 @@
    File file = path.toFile();
    if ( file.exists() )
    {
-    IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
-    if ( f != null )
+    try
+    {
+     path = new Path( file.getCanonicalPath() );
+     IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( path );
+     if ( f != null )
+     {
+      return f;
+     }
+     return createExternalFileStorage( path );
+    }
+    catch( IOException e )
     {
-     return f;
-    }
-    return createExternalFileStorage( path );
+    }
    }
   }
   return null;
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java,v
retrieving revision 1.11
diff -u -r1.11 CProjectSourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 28 Jul 2003 19:40:22 -0000 1.11
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 16 Sep 2003 18:38:54 -0000
@@ -30,7 +30,6 @@
 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 @@
 
  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 )
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java,v
retrieving revision 1.16
diff -u -r1.16 CSourceLocator.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 30 Jul 2003 20:22:31 -0000 1.16
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 16 Sep 2003 18:38:55 -0000
@@ -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 @@
 
  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() )
-   {
-    return f;
-   }
-   return new FileStorage( path );
+   try
+   {
+    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;
  }

Back to the top