fileattributes exception fix - reading again workaround

This commit is contained in:
Jindra Petřík
2014-08-24 07:09:50 +02:00
parent 1711273a69
commit ff4484d066
@@ -1010,6 +1010,9 @@ public class SWFInputStream implements AutoCloseable {
executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get()); executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get());
futureResults = new ArrayList<>(); futureResults = new ArrayList<>();
} }
int tagCnt = 0;
int faPos = 0;
FileAttributesTag fileAttributes = null;
List<Tag> tags = new ArrayList<>(); List<Tag> tags = new ArrayList<>();
Tag tag; Tag tag;
boolean isAS3 = false; boolean isAS3 = false;
@@ -1021,6 +1024,7 @@ public class SWFInputStream implements AutoCloseable {
} catch (EOFException | EndOfStreamException ex) { } catch (EOFException | EndOfStreamException ex) {
tag = null; tag = null;
} }
tagCnt++;
DumpInfo di = dumpInfo; DumpInfo di = dumpInfo;
if (di != null && tag != null) { if (di != null && tag != null) {
di.name = tag.getName(); di.name = tag.getName();
@@ -1044,11 +1048,11 @@ public class SWFInputStream implements AutoCloseable {
} else { } else {
switch (tag.getId()) { switch (tag.getId()) {
case FileAttributesTag.ID: //FileAttributes case FileAttributesTag.ID: //FileAttributes
Tag ft = tag; faPos = tagCnt-1; //should be 0, as it is first tag, but anyway
if (ft instanceof TagStub) { if (tag instanceof TagStub) {
ft = resolveTag((TagStub) tag, level, parallel, skipUnusualTags); tag = resolveTag((TagStub) tag, level, parallel, skipUnusualTags);
} }
FileAttributesTag fileAttributes = (FileAttributesTag) ft; fileAttributes = (FileAttributesTag) tag;
if (fileAttributes.actionScript3) { if (fileAttributes.actionScript3) {
isAS3 = true; isAS3 = true;
} }
@@ -1112,6 +1116,10 @@ public class SWFInputStream implements AutoCloseable {
executor.shutdown(); executor.shutdown();
} }
//Workaround to not reading fileattributes twice. TODO:Handle this better
if(parallel && fileAttributes!=null){
tags.add(faPos,fileAttributes);
}
return tags; return tags;
} }