+package org.xwt.translators;
+import org.xwt.*;
+import org.xwt.util.*;
+import java.io.*;
+import java.util.zip.*;
+
+public class MSPack {
+
+ MSPack() { }
+
+ private static org.xwt.mips.Interpreter vm = null;
+
+ public static synchronized void unpack(InputStream theCabFile) {
+ try {
+ if (vm == null) {
+ InputStream bis = Platform.getBuiltinInputStream();
+ ZipInputStream zis = new ZipInputStream(bis);
+ for(ZipEntry ze = zis.getNextEntry(); ze != null && !ze.getName().equals("libmspack.mips"); ze = zis.getNextEntry()) { }
+ byte[] image = InputStreamToByteArray.convert(zis);
+ vm = new org.xwt.mips.Interpreter(image);
+ vm.start(new String[]{ "libmspack.mips" });
+ vm.execute();
+ }
+
+ int CAB_RESERVED = 256*1024;
+ int baseAddr = vm.sbrk(CAB_RESERVED);
+
+ byte[] cabstream = InputStreamToByteArray.convert(theCabFile);
+ vm.copyout(cabstream, baseAddr, cabstream.length);
+ vm.setUserInfo(0, baseAddr);
+ vm.setUserInfo(1, cabstream.length);
+
+ vm.execute();
+ // FIXME: do more stuff here
+
+ } catch (Exception e) {
+ Log.log(MSPack.class, e);
+ }
+ }
+}