Skip to content

Get zip file processing working #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/src/com/sonyericsson/chkbugreport/BugReportModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class BugReportModule extends Module {

private static final String TYPE_BUGREPORT = "!BUGREPORT";

private static final String FILENAME_SPLIT = ".zip:bugreport";

private Vector<ProcessRecord> mProcessRecords = new Vector<ProcessRecord>();
private HashMap<Integer, ProcessRecord> mProcessRecordMap = new HashMap<Integer, ProcessRecord>();
private Chapter mChProcesses;
Expand Down Expand Up @@ -593,6 +595,9 @@ private boolean autodetectFile(String fileName, boolean limitSize) {
Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if(!entry.getName().startsWith("bugreport")) {
continue;
}
if (!entry.isDirectory()) {
if (!getContext().isSilent()) {
System.out.println("Trying to parse zip entry: " + entry.getName() + " ...");
Expand Down Expand Up @@ -620,7 +625,7 @@ private boolean autodetectFile(String fileName, boolean limitSize) {
private void autodetectFile(String fileName, InputStream origIs) {
final int buffSize = 0x1000;
InputStream is = new BufferedInputStream(origIs, buffSize);

boolean isZip = fileName.contains(FILENAME_SPLIT);
// Try to open it as gzip
try {
is.mark(buffSize);
Expand Down Expand Up @@ -660,9 +665,10 @@ private void autodetectFile(String fileName, InputStream origIs) {
// Load the file and generate the report
if (type.get().equals(TYPE_BUGREPORT)) {
try {
String outputFileName = isZip ? fileName.substring(0, fileName.indexOf(FILENAME_SPLIT)): fileName;
load(is);
setSource(new SourceFile(fileName, TYPE_BUGREPORT));
setFileName(fileName, 100);
setFileName(outputFileName, 100);
} catch (IOException e) {
throw new IllegalParameterException("Not a bugreport file");
}
Expand Down