2003/09/19 09:16:00
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:35:57 +0000 (07:35 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:35:57 +0000 (07:35 +0000)
darcs-hash:20040130073557-2ba56-2e2c10f67f6df26fdb590d7c7b4c1d8025f4112e.gz

src/org/xwt/Res.java
src/org/xwt/util/CAB.java

index f0b25bf..8f7906a 100644 (file)
@@ -103,15 +103,22 @@ public abstract class Res extends JS {
             return ((i & 0xff) << 24) | ((i & 0xff00) << 8) | ((i & 0xff0000) >>> 8) | (i >>> 24);
         }
         public InputStream getInputStream(String path) throws IOException {
-            InputStream is = new InputStream(parent.getInputStream());
+            InputStream is = parent.getInputStream();
             byte[] scan = new byte[4];
-            while(scan[0] != 'M' || scan[1] != 'S' || scan[2] != 'C' || scan[3] != 'F') {
-                System.arraycopy(scan, 1, scan, 0, 3);
-                int read = is.read();
-                if (read == -1) throw new JS.Exn("MSCF header tag not found in file");
-                scan[3] = (byte)read;
+            int ofs = 0;
+            for(int i=0; i<2; i++)  {
+                // wierdly, .exe files have three MSCF's
+                while(scan[0] != 'M' || scan[1] != 'S' || scan[2] != 'C' || scan[3] != 'F') {
+                    System.arraycopy(scan, 1, scan, 0, 3);
+                    int read = is.read();
+                    if (read == -1) throw new JS.Exn("MSCF header tag not found in file");
+                    scan[3] = (byte)read;
+                    ofs++;
+                }
+                scan[0] = 0;
             }
-            return org.xwt.util.CAB.getFileInputStream(is, path);
+            Log.log(this, "found MSCF header at offset " + ofs);
+            return org.xwt.util.CAB.getFileInputStream(is, path, true);
         }
     }
 
index e178135..ebea9c1 100644 (file)
@@ -1,5 +1,5 @@
 // Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
-package org.xwt.shoehorn3;
+package org.xwt.util;
 
 import java.io.*;
 import java.util.*;
@@ -194,7 +194,7 @@ public class CAB {
         int      numBlocks = 0;                 // number of data blocks
         int      compressionType = 0;           // compression type for this folder
         byte[]   reservedArea = null;           // per-folder reserved area
-        int      indexInCFHEADER = 0;             // our index in CFHEADER.folders
+        int      indexInCFHEADER = 0;           // our index in CFHEADER.folders
         Vector   files = new Vector();
 
         private CFHEADER header = null;