gzip support

This commit is contained in:
sirjonasxx 2022-02-09 21:33:25 +01:00
parent ebf899e271
commit 3a76c4ba9d
2 changed files with 23 additions and 4 deletions

View File

@ -10,5 +10,18 @@ public class GWasm {
public static void main(String[] args) throws IOException, InvalidOpCodeException { public static void main(String[] args) throws IOException, InvalidOpCodeException {
long start = System.currentTimeMillis();
Module module = new Module("C:\\Users\\jonas\\Desktop\\Projects\\Jznnp\\S\\habbo2020\\rawfiles\\0.23.0_(534)\\habbo2020-global-prod.wasm.gz", true, new ArrayList<>());
long end = System.currentTimeMillis();
System.out.println("Disassemble time: " + (end - start));
start = System.currentTimeMillis();
module.assembleToFile("C:\\Users\\jonas\\Desktop\\Projects\\Jznnp\\S\\habbo2020\\rawfiles\\0.23.0_(534)\\out\\habbo2020-global-prod.wasm.gz", true);
end = System.currentTimeMillis();
System.out.println("Assemble time: " + (end - start));
System.out.println("hi");
} }
} }

View File

@ -21,6 +21,8 @@ import wasm.misc.StreamReplacement;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class Module extends WASMOpCode { public class Module extends WASMOpCode {
@ -80,8 +82,12 @@ public class Module extends WASMOpCode {
in.close(); in.close();
} }
public Module(String fileName, List<StreamReplacement> streamReplacements) throws IOException, InvalidOpCodeException { public Module(String fileName, boolean gzip, List<StreamReplacement> streamReplacements) throws IOException, InvalidOpCodeException {
this(new BufferedInputStream(new FileInputStream(new File(fileName))), streamReplacements); this(new BufferedInputStream(gzip ?
new GZIPInputStream(new FileInputStream(new File(fileName))) :
new FileInputStream(new File(fileName)))
, streamReplacements
);
} }
private void disassembleCustomSections(BufferedInputStream in) throws IOException, InvalidOpCodeException { private void disassembleCustomSections(BufferedInputStream in) throws IOException, InvalidOpCodeException {
@ -129,8 +135,8 @@ public class Module extends WASMOpCode {
} }
} }
public void assembleToFile(String fileName) throws IOException, InvalidOpCodeException { public void assembleToFile(String fileName, boolean gzip) throws IOException, InvalidOpCodeException {
assemble(new FileOutputStream(fileName)); assemble(gzip ? new GZIPOutputStream(new FileOutputStream(fileName)) : new FileOutputStream(fileName));
} }
public Magic getMagic() { public Magic getMagic() {