mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
cleanup
reduced # of open/close pre elf file
This commit is contained in:
parent
8daef5ac9c
commit
de98fe1839
3 changed files with 15 additions and 13 deletions
|
@ -26,8 +26,9 @@ public class ElfBinaryArchive extends PlatformObject implements IBinaryArchive {
|
|||
ArrayList children;
|
||||
long timestamp;
|
||||
|
||||
public ElfBinaryArchive(IPath p) {
|
||||
public ElfBinaryArchive(IPath p) throws IOException {
|
||||
path = p;
|
||||
new AR(path.toOSString()).dispose(); // check file type
|
||||
children = new ArrayList(5);
|
||||
}
|
||||
|
||||
|
|
|
@ -274,9 +274,15 @@ public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinar
|
|||
}
|
||||
|
||||
protected void loadInformation() throws IOException {
|
||||
ElfHelper helper = getElfHelper();
|
||||
loadInformation(helper);
|
||||
helper.dispose();
|
||||
ElfHelper helper = null;
|
||||
try {
|
||||
helper = getElfHelper();
|
||||
loadInformation(helper);
|
||||
} finally {
|
||||
if (helper != null) {
|
||||
helper.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadInformation(ElfHelper helper) throws IOException {
|
||||
|
|
|
@ -9,8 +9,6 @@ import java.io.IOException;
|
|||
|
||||
import org.eclipse.cdt.core.AbstractCExtension;
|
||||
import org.eclipse.cdt.core.IBinaryParser;
|
||||
import org.eclipse.cdt.utils.elf.AR;
|
||||
import org.eclipse.cdt.utils.elf.Elf;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
@ -25,16 +23,13 @@ public class ElfParser extends AbstractCExtension implements IBinaryParser {
|
|||
if (path == null ) {
|
||||
path = new Path("");
|
||||
}
|
||||
IBinaryFile bFile;
|
||||
try {
|
||||
Elf e = new Elf(path.toOSString());
|
||||
e.dispose();
|
||||
return new ElfBinaryFile(path);
|
||||
bFile = new ElfBinaryFile(path);
|
||||
} catch (IOException e) {
|
||||
bFile = new ElfBinaryArchive(path);
|
||||
}
|
||||
// Is it an Archive.
|
||||
AR ar = new AR(path.toOSString());
|
||||
ar.dispose();
|
||||
return new ElfBinaryArchive(path);
|
||||
return bFile;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue