Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] First change in the Binary Parser to reflect the proposal.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.69
diff -u -r1.69 ChangeLog
--- ChangeLog	26 Feb 2003 21:01:28 -0000	1.69
+++ ChangeLog	26 Feb 2003 21:35:39 -0000
@@ -1,3 +1,26 @@
+2003-02-26 Alain Magloire
+
+	A new proposal was make, see cdt-core-home/docs/binarparser.html
+	it changed the the signature:
+	public interface IBinaryParser {
+		IBinary getBinary(IPath path);
+	}
+
+	The getBinary() method no longer takes an IFile, this was necessary
+	to allow the binary parser code to work on files outside of the
+	workspace.  The correspondign implementation is updated.
+	
+	* model/org/eclipse/cdt/internal/core/model/ElfBinaryArchive.java
+	* model/org/eclipse/cdt/internal/core/model/ElfBinaryFile.java
+	* model/org/eclipse/cdt/internal/core/model/ElfParser.java
+	* model/org/eclipse/cdt/internal/core/model/PEBinaryArchive.java
+	* model/org/eclipse/cdt/internal/core/model/PEBinaryFile.java
+	* model/org/eclipse/cdt/internal/core/model/PEBParser.java
+
+	* model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java
+	* model/org/eclipse/cdt/internal/core/model/BinaryInfo.java
+	* model/org/eclipse/cdt/internal/core/model/CModelManager.java
+
 2003-02-26 David Inglis
 	* model/org/eclipse/cdt/internal/core/model/ArchiveContainer.java
 	* model/org/eclipse/cdt/internal/core/model/BinaryContainer.java
Index: model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java,v
retrieving revision 1.4
diff -u -r1.4 ArchiveInfo.java
--- model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java	23 Feb 2003 19:23:40 -0000	1.4
+++ model/org/eclipse/cdt/internal/core/model/ArchiveInfo.java	26 Feb 2003 21:35:39 -0000
@@ -13,9 +13,9 @@
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
 
 /** 
  * Info for ICProject.
@@ -73,8 +73,8 @@
 			IBinaryParser parser = CModelManager.getDefault().getBinaryParser(project);
 			if (parser != null) {
 				try {
-					IFile file = (IFile) getElement().getUnderlyingResource();
-					IBinaryFile bfile = parser.getBinary(file);
+					IPath path = getElement().getUnderlyingResource().getLocation();
+					IBinaryFile bfile = parser.getBinary(path);
 					if (bfile instanceof IBinaryArchive) {
 						archive = (IBinaryArchive) bfile;
 					}
Index: model/org/eclipse/cdt/internal/core/model/BinaryInfo.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryInfo.java,v
retrieving revision 1.6
diff -u -r1.6 BinaryInfo.java
--- model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	23 Feb 2003 19:23:40 -0000	1.6
+++ model/org/eclipse/cdt/internal/core/model/BinaryInfo.java	26 Feb 2003 21:35:39 -0000
@@ -18,7 +18,6 @@
 import org.eclipse.cdt.core.IBinaryParser.ISymbol;
 import org.eclipse.cdt.core.model.CModelException;
 import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -167,8 +166,8 @@
 			IBinaryParser parser = CModelManager.getDefault().getBinaryParser(project);
 			if (parser != null) {
 				try {
-					IFile file = (IFile) getElement().getUnderlyingResource();
-					IBinaryFile bfile = parser.getBinary(file);
+					IPath path = getElement().getUnderlyingResource().getLocation();
+					IBinaryFile bfile = parser.getBinary(path);
 					if (bfile instanceof IBinaryObject) {
 						binary = (IBinaryObject) bfile;
 					}
Index: model/org/eclipse/cdt/internal/core/model/CModelManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java,v
retrieving revision 1.13
diff -u -r1.13 CModelManager.java
--- model/org/eclipse/cdt/internal/core/model/CModelManager.java	23 Jan 2003 16:40:04 -0000	1.13
+++ model/org/eclipse/cdt/internal/core/model/CModelManager.java	26 Feb 2003 21:35:39 -0000
@@ -461,7 +461,7 @@
 	public boolean isSharedLib(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
-			IBinaryFile bin = parser.getBinary(file);
+			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.SHARED);
 		} catch (IOException e) {
 			//e.printStackTrace();
@@ -472,7 +472,7 @@
 	public boolean isObject(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
-			IBinaryFile bin = parser.getBinary(file);
+			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.OBJECT);
 		} catch (IOException e) {
 			//e.printStackTrace();
@@ -483,7 +483,7 @@
 	public boolean isExecutable(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
-			IBinaryFile bin = parser.getBinary(file);
+			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.EXECUTABLE);
 		} catch (IOException e) {
 			//e.printStackTrace();
@@ -494,7 +494,7 @@
 	public boolean isBinary(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
-			IBinaryFile bin = parser.getBinary(file);
+			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.EXECUTABLE
 				|| bin.getType() == IBinaryFile.OBJECT
 				|| bin.getType() == IBinaryFile.SHARED
@@ -508,7 +508,7 @@
 	public boolean isArchive(IFile file) {
 		try {
 			IBinaryParser parser = getBinaryParser(file.getProject());
-			IBinaryFile bin = parser.getBinary(file);
+			IBinaryFile bin = parser.getBinary(file.getLocation());
 			return (bin.getType() == IBinaryFile.ARCHIVE);
 		} catch (IOException e) {
 			//e.printStackTrace();
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java,v
retrieving revision 1.4
diff -u -r1.4 ElfBinaryArchive.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java	26 Feb 2003 21:01:28 -0000	1.4
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryArchive.java	26 Feb 2003 21:35:39 -0000
@@ -6,6 +6,7 @@
  */
  
 import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -14,8 +15,6 @@
 import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.utils.elf.AR;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.PlatformObject;
 
@@ -23,12 +22,12 @@
  */
 public class ElfBinaryArchive extends PlatformObject implements IBinaryArchive {
 
-	IFile file;
+	IPath path;
 	ArrayList children;
 	long timestamp;
 	
-	public ElfBinaryArchive(IFile f) {
-		file = f;
+	public ElfBinaryArchive(IPath p) {
+		path = p;
 		children = new ArrayList(5);
 	}
 
@@ -38,14 +37,13 @@
 	public IBinaryObject[] getObjects() {
 		if (hasChanged()) {
 			children.clear();
-			IPath location = file.getLocation();
-			if (location != null) {
+			if (path != null) {
 				AR ar = null;
 				try {
-					ar = new AR(location.toOSString());
+					ar = new AR(path.toOSString());
 					AR.ARHeader[] headers = ar.getHeaders();
 					for (int i = 0; i < headers.length; i++) {
-						IBinaryObject bin = new ElfBinaryFile(file, headers[i]);
+						IBinaryObject bin = new ElfBinaryFile(path, headers[i]);
 						children.add(bin);
 					}
 				} catch (IOException e) {
@@ -63,8 +61,8 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
 	 */
-	public IFile getFile() {
-		return file;
+	public IPath getPath() {
+		return path;
 	}
 
 	/**
@@ -79,14 +77,14 @@
 	 */
 	public InputStream getContents() {
 		try {
-			return file.getContents();
-		} catch (CoreException e) {
+			return new FileInputStream(path.toFile());
+		} catch (IOException e) {
 		}
 		return new ByteArrayInputStream(new byte[0]);
 	}
 
 	boolean hasChanged() {
-		long modif = file.getModificationStamp();
+		long modif = path.toFile().lastModified();
 		boolean changed = modif != timestamp;
 		timestamp = modif;
 		return changed;
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java,v
retrieving revision 1.6
diff -u -r1.6 ElfBinaryFile.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java	26 Feb 2003 21:01:28 -0000	1.6
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java	26 Feb 2003 21:35:40 -0000
@@ -6,6 +6,7 @@
  */
 
 import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -20,16 +21,13 @@
 import org.eclipse.cdt.utils.elf.ElfHelper;
 import org.eclipse.cdt.utils.elf.Elf.Attribute;
 import org.eclipse.cdt.utils.elf.ElfHelper.Sizes;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.PlatformObject;
 
 /**
  */
 public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinaryObject, IBinaryExecutable, IBinaryShared {
-	IFile file;
+	IPath path;
 	AR.ARHeader header;
 	long timestamp;
 	String soname;
@@ -38,13 +36,13 @@
 	Attribute attribute;
 	ArrayList symbols;
 
-	public ElfBinaryFile(IFile f) throws IOException {
-		this(f, null);
+	public ElfBinaryFile(IPath p) throws IOException {
+		this(p, null);
 	}
 
-	public ElfBinaryFile(IFile f, AR.ARHeader h) throws IOException {
+	public ElfBinaryFile(IPath p, AR.ARHeader h) throws IOException {
 		header = h;
-		file = f;
+		path = p;
 		loadInformation();
 		hasChanged();
 	}
@@ -52,8 +50,8 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
 	 */
-	public IFile getFile() {
-		return file;
+	public IPath getPath() {
+		return path;
 	}
 
 	/**
@@ -204,15 +202,15 @@
 	public InputStream getContents() {
 		InputStream stream = null;
 		// Archive ?
-		if (file != null && header != null) {
+		if (path != null && header != null) {
 			try {
 				stream = new ByteArrayInputStream(header.getObjectData());
 			} catch (IOException e) {
 			}
-		} else if (file != null && file.exists()) {
+		} else if (path != null) {
 			try {
-				stream = file.getContents();
-			} catch (CoreException e) {
+				stream = new FileInputStream(path.toFile());
+			} catch (IOException e) {
 			}
 		}
 		if (stream == null) {
@@ -228,8 +226,8 @@
 		if (header != null) {
 			return header.getObjectName();
 		}
-		if (file != null) {
-			return file.getName();
+		if (path != null) {
+			return path.lastSegment().toString();
 		}
 		return "";
 	}
@@ -259,7 +257,7 @@
 	}
 
 	boolean hasChanged() {
-		long modification = file.getModificationStamp();
+		long modification = path.toFile().lastModified();
 		boolean changed = modification != timestamp;
 		timestamp = modification;
 		return changed;
@@ -269,11 +267,7 @@
 		// Archive ?
 		if (header != null) {
 			return new ElfHelper(header.getElf());
-		} else if (file != null && file.exists()) {
-			IPath path = file.getLocation();
-			if (path == null) {
-				path = new Path("");
-			}
+		} else if (path != null) {
 			return new ElfHelper(path.toOSString());
 		}
 		throw new IOException("No file assiocated with Binary");
Index: model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java,v
retrieving revision 1.3
diff -u -r1.3 ElfParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	27 Nov 2002 04:44:46 -0000	1.3
+++ model/org/eclipse/cdt/internal/core/model/parser/ElfParser.java	26 Feb 2003 21:35:40 -0000
@@ -10,7 +10,7 @@
 import org.eclipse.cdt.core.IBinaryParser;
 import org.eclipse.cdt.utils.elf.AR;
 import org.eclipse.cdt.utils.elf.Elf;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
 
 /**
  */
@@ -19,17 +19,17 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath)
 	 */
-	public IBinaryFile getBinary(IFile file) throws IOException {
+	public IBinaryFile getBinary(IPath path) throws IOException {
 		try {
-			Elf e = new Elf(file.getLocation().toOSString());
+			Elf e = new Elf(path.toOSString());
 			e.dispose();
-			return new ElfBinaryFile(file);
+			return new ElfBinaryFile(path);
 		} catch (IOException e) {
 		}
 		// Is it an Archive.
-		AR ar = new AR(file.getLocation().toOSString()); 
+		AR ar = new AR(path.toOSString()); 
 		ar.dispose();
-		return new ElfBinaryArchive(file);
+		return new ElfBinaryArchive(path);
 	}
 
 	/**
Index: model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java,v
retrieving revision 1.2
diff -u -r1.2 PEBinaryArchive.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java	27 Nov 2002 04:44:46 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/parser/PEBinaryArchive.java	26 Feb 2003 21:35:40 -0000
@@ -6,6 +6,8 @@
  */
  
 import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -14,8 +16,6 @@
 import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
 import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
 import org.eclipse.cdt.utils.coff.PEArchive;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.PlatformObject;
 
@@ -23,12 +23,12 @@
  */
 public class PEBinaryArchive extends PlatformObject implements IBinaryArchive {
 
-	IFile file;
+	IPath path;
 	ArrayList children;
 	long timestamp;
 	
-	public PEBinaryArchive(IFile f) {
-		file = f;
+	public PEBinaryArchive(IPath p) {
+		path = p;
 		children = new ArrayList(5);
 	}
 
@@ -38,14 +38,13 @@
 	public IBinaryObject[] getObjects() {
 		if (hasChanged()) {
 			children.clear();
-			IPath location = file.getLocation();
-			if (location != null) {
+			if (path != null) {
 				PEArchive ar = null;
 				try {
-					ar = new PEArchive(location.toOSString());
+					ar = new PEArchive(path.toOSString());
 					PEArchive.ARHeader[] headers = ar.getHeaders();
 					for (int i = 0; i < headers.length; i++) {
-						IBinaryObject bin = new PEBinaryFile(file, headers[i].getObjectName());
+						IBinaryObject bin = new PEBinaryFile(path, headers[i].getObjectName());
 						children.add(bin);
 					}
 				} catch (IOException e) {
@@ -63,8 +62,8 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
 	 */
-	public IFile getFile() {
-		return file;
+	public IPath getPath() {
+		return path;
 	}
 
 	/**
@@ -79,17 +78,21 @@
 	 */
 	public InputStream getContents() {
 		try {
-			return file.getContents();
-		} catch (CoreException e) {
+			return new FileInputStream(path.toFile());
+		} catch (IOException e) {
 		}
 		return new ByteArrayInputStream(new byte[0]);
 	}
 
 	boolean hasChanged() {
-		long modif = file.getModificationStamp();
-		boolean changed = modif != timestamp;
-		timestamp = modif;
-		return changed;
+		File file = path.toFile();
+		if (file != null && file.exists()) {
+			long modification = file.lastModified();
+			boolean changed = modification != timestamp;
+			timestamp = modification;
+			return changed;
+		}
+		return false;
 	}
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryArchive#add(IBinaryObject[])
Index: model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java,v
retrieving revision 1.2
diff -u -r1.2 PEBinaryFile.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java	27 Nov 2002 04:44:46 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java	26 Feb 2003 21:35:40 -0000
@@ -5,6 +5,8 @@
  */
 
 import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -18,10 +20,7 @@
 import org.eclipse.cdt.utils.coff.PE;
 import org.eclipse.cdt.utils.coff.PEArchive;
 import org.eclipse.cdt.utils.coff.PE.Attribute;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.PlatformObject;
 
 /**
@@ -29,18 +28,18 @@
 public class PEBinaryFile extends PlatformObject implements IBinaryFile, 
 	IBinaryObject, IBinaryExecutable, IBinaryShared {
 
-	IFile file;
+	IPath path;
 	long timestamp;
 	PE.Attribute attribute;
 	String objectName;
 	ArrayList symbols;
 
-	public PEBinaryFile(IFile file) throws IOException {
-		this(file, null);
+	public PEBinaryFile(IPath p) throws IOException {
+		this(p, null);
 	}
 	
-	public PEBinaryFile(IFile file, String o) throws IOException {
-		this.file = file;
+	public PEBinaryFile(IPath p, String o) throws IOException {
+		path = p;
 		objectName = o;
 		loadInformation();
 		hasChanged();
@@ -51,30 +50,28 @@
 	 */
 	public InputStream getContents() {
 		InputStream stream = null;
-		if (file != null && objectName != null) {
-			IPath location = file.getLocation();
-			if (location != null) {
-				PEArchive ar = null;
-				try {   
-					ar = new PEArchive(file.getLocation().toOSString());
-					PEArchive.ARHeader[] headers = ar.getHeaders();
-					for (int i = 0; i < headers.length; i++) {
-						PEArchive.ARHeader hdr = headers[i];
-						if (objectName.equals(hdr.getObjectName())) {
-							stream = new ByteArrayInputStream(hdr.getObjectData());
-							break;
-						}
+		if (path != null && objectName != null) {
+			PEArchive ar = null;
+			try {   
+				ar = new PEArchive(path.toOSString());
+				PEArchive.ARHeader[] headers = ar.getHeaders();
+				for (int i = 0; i < headers.length; i++) {
+					PEArchive.ARHeader hdr = headers[i];
+					if (objectName.equals(hdr.getObjectName())) {
+						stream = new ByteArrayInputStream(hdr.getObjectData());
+						break;
 					}
-				} catch (IOException e) {
 				}
+			} catch (IOException e) {
+			} finally {
 				if (ar != null) {
 					ar.dispose();
 				}
 			}
-		} else if (file != null && file.exists()) {
+		} else if (path != null) {
 			try {
-				stream = file.getContents();
-			} catch (CoreException e) {
+				stream = new FileInputStream (path.toFile());
+			} catch (IOException e) {
 			}
 		}
 		if (stream == null) {
@@ -86,8 +83,8 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile()
 	 */
-	public IFile getFile() {
-		return file;
+	public IPath getPath() {
+		return path;
 	}
 
 	/**
@@ -149,8 +146,8 @@
 	public String getName() {
 		if (objectName != null) {
 			return objectName;
-		} else if (file != null) {
-			return file.getName();
+		} else if (path != null) {
+			return path.lastSegment().toString();
 		}
 		return "";
 	}
@@ -215,35 +212,28 @@
 	}
 
 	protected PE getPE() throws IOException {
-		if (file != null && objectName != null) {
-			IPath location = file.getLocation();
-			if (location != null) { 
-				PE pe = null;
-				PEArchive ar = null;
-				try {
-					ar = new PEArchive(file.getLocation().toOSString());
-					PEArchive.ARHeader[] headers = ar.getHeaders();
-					for (int i = 0; i < headers.length; i++) {
-						PEArchive.ARHeader hdr = headers[i];
-						if (objectName.equals(hdr.getObjectName())) {
-							pe = hdr.getPE();
-							break;
-						}
-					}
-				} finally {
-					if (ar != null) {
-						ar.dispose();
+		if (path != null && objectName != null) {
+			PE pe = null;
+			PEArchive ar = null;
+			try {
+				ar = new PEArchive(path.toOSString());
+				PEArchive.ARHeader[] headers = ar.getHeaders();
+				for (int i = 0; i < headers.length; i++) {
+					PEArchive.ARHeader hdr = headers[i];
+					if (objectName.equals(hdr.getObjectName())) {
+						pe = hdr.getPE();
+						break;
 					}
 				}
-				if (pe != null) {
-					return pe; 
+			} finally {
+				if (ar != null) {
+					ar.dispose();
 				}
 			}
-		} else if (file != null && file.exists()) {
-			IPath path = file.getLocation();
-			if (path == null) {
-				path = new Path("");
+			if (pe != null) {
+				return pe; 
 			}
+		} else if (path != null) {
 			return new PE(path.toOSString());
 		}
 		throw new IOException("No file assiocated with Binary");
@@ -299,10 +289,14 @@
 	}
 
 	boolean hasChanged() {
-		long modification = file.getModificationStamp();
-		boolean changed = modification != timestamp;
-		timestamp = modification;
-		return changed;
+		File file = path.toFile();
+		if (file != null && file.exists()) {
+			long modification = file.lastModified();
+			boolean changed = modification != timestamp;
+			timestamp = modification;
+			return changed;
+		}
+		return false;
 	}
 
 }
Index: model/org/eclipse/cdt/internal/core/model/parser/PEParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEParser.java,v
retrieving revision 1.2
diff -u -r1.2 PEParser.java
--- model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	27 Nov 2002 04:44:46 -0000	1.2
+++ model/org/eclipse/cdt/internal/core/model/parser/PEParser.java	26 Feb 2003 21:35:40 -0000
@@ -10,7 +10,7 @@
 import org.eclipse.cdt.core.IBinaryParser;
 import org.eclipse.cdt.utils.coff.PE;
 import org.eclipse.cdt.utils.coff.PEArchive;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
 
 /**
  */
@@ -19,17 +19,17 @@
 	/**
 	 * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IFile)
 	 */
-	public IBinaryFile getBinary(IFile file) throws IOException {
+	public IBinaryFile getBinary(IPath path) throws IOException {
 		try {
-			PE pe = new PE(file.getLocation().toOSString());
+			PE pe = new PE(path.toOSString());
 			pe.dispose();
-			return new PEBinaryFile(file);
+			return new PEBinaryFile(path);
 		} catch (IOException e) {
 		}
 		// Is it an Archive.
-		PEArchive ar = new PEArchive(file.getLocation().toOSString());
+		PEArchive ar = new PEArchive(path.toOSString());
 		ar.dispose();
-		return new PEBinaryArchive(file);
+		return new PEBinaryArchive(path);
 	}
 
 	/**
Index: src/org/eclipse/cdt/core/IBinaryParser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java,v
retrieving revision 1.1
diff -u -r1.1 IBinaryParser.java
--- src/org/eclipse/cdt/core/IBinaryParser.java	27 Nov 2002 04:47:10 -0000	1.1
+++ src/org/eclipse/cdt/core/IBinaryParser.java	26 Feb 2003 21:35:40 -0000
@@ -8,8 +8,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
 
 /**
  */
@@ -25,7 +25,7 @@
 		public int ARCHIVE = 0x08;
 		public int CORE = 0x10;
 
-		public IFile getFile();
+		public IPath getPath();
 		public int getType();
 		public InputStream getContents();
 	}
@@ -84,7 +84,7 @@
 		public int getType();
 	}
 
-	public IBinaryFile getBinary(IFile file) throws IOException;
+	public IBinaryFile getBinary(IPath path) throws IOException;
 	
 	public String getFormat();
 }



Back to the top