Script search history fixes - reading AS3 results

This commit is contained in:
Jindra Petřík
2021-02-24 19:55:59 +01:00
parent 573d9ca384
commit b82d6b62fe
6 changed files with 35 additions and 33 deletions
@@ -12,17 +12,19 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.graph.DottedChain;
import java.io.Serializable;
import java.util.Objects;
/**
*
* @author JPEXS
*/
public class ClassPath {
public class ClassPath implements Serializable {
public final DottedChain packageStr;
@@ -55,11 +55,10 @@ public class ABCSearchResult implements Serializable {
private final int traitId;
@SuppressWarnings("unchecked")
public ABCSearchResult(SWF swf, InputStream is) throws IOException, ScriptNotFoundException {
ObjectInputStream ois = new ObjectInputStream(is);
public ABCSearchResult(SWF swf, ObjectInputStream ois) throws IOException, ScriptNotFoundException {
int versionMajor = ois.read();
ois.read(); //minor
if (versionMajor != -1) {
if (versionMajor != 1) {
throw new IOException("Unknown search result version");
}
@@ -89,8 +88,7 @@ public class ABCSearchResult implements Serializable {
}
}
public void save(OutputStream os) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(os);
public void save(ObjectOutputStream oos) throws IOException {
oos.write(1); //version major
oos.write(0); //version minor
oos.writeObject(scriptPack.getClassPath());
@@ -22,6 +22,8 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Map;
@@ -37,22 +39,20 @@ public class ActionSearchResult {
private final String path;
public ActionSearchResult(SWF swf, InputStream is) throws IOException, ScriptNotFoundException {
public ActionSearchResult(SWF swf, ObjectInputStream ois) throws IOException, ScriptNotFoundException {
Map<String, ASMSource> asms = swf.getASMs(false);
DataInputStream dais = new DataInputStream(is);
path = dais.readUTF();
path = ois.readUTF();
if (asms.containsKey(path)) {
src = asms.get(path);
} else {
throw new ScriptNotFoundException();
}
pcode = dais.readBoolean();
pcode = ois.readBoolean();
}
public void save(OutputStream os) throws IOException {
DataOutputStream daos = new DataOutputStream(os);
daos.writeUTF(path);
daos.writeBoolean(pcode);
public void save(ObjectOutputStream oos) throws IOException {
oos.writeUTF(path);
oos.writeBoolean(pcode);
}
public ActionSearchResult(ASMSource src, boolean pcode, String path) {