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;
|
ArrayList children;
|
||||||
long timestamp;
|
long timestamp;
|
||||||
|
|
||||||
public ElfBinaryArchive(IPath p) {
|
public ElfBinaryArchive(IPath p) throws IOException {
|
||||||
path = p;
|
path = p;
|
||||||
|
new AR(path.toOSString()).dispose(); // check file type
|
||||||
children = new ArrayList(5);
|
children = new ArrayList(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,9 +274,15 @@ public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinar
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadInformation() throws IOException {
|
protected void loadInformation() throws IOException {
|
||||||
ElfHelper helper = getElfHelper();
|
ElfHelper helper = null;
|
||||||
loadInformation(helper);
|
try {
|
||||||
helper.dispose();
|
helper = getElfHelper();
|
||||||
|
loadInformation(helper);
|
||||||
|
} finally {
|
||||||
|
if (helper != null) {
|
||||||
|
helper.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInformation(ElfHelper helper) throws IOException {
|
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.AbstractCExtension;
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
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.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -25,16 +23,13 @@ public class ElfParser extends AbstractCExtension implements IBinaryParser {
|
||||||
if (path == null ) {
|
if (path == null ) {
|
||||||
path = new Path("");
|
path = new Path("");
|
||||||
}
|
}
|
||||||
|
IBinaryFile bFile;
|
||||||
try {
|
try {
|
||||||
Elf e = new Elf(path.toOSString());
|
bFile = new ElfBinaryFile(path);
|
||||||
e.dispose();
|
|
||||||
return new ElfBinaryFile(path);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
bFile = new ElfBinaryArchive(path);
|
||||||
}
|
}
|
||||||
// Is it an Archive.
|
return bFile;
|
||||||
AR ar = new AR(path.toOSString());
|
|
||||||
ar.dispose();
|
|
||||||
return new ElfBinaryArchive(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue