All pastes #396887 Raw Edit

Something

public text v1 · immutable
·published 2007-03-16 02:21 UTC
rendered paste body

    public static byte[] Unpack1(ByteStream f, String fpath)
    {
        if(f.ReadUnsignedByte() == 31 && f.ReadUnsignedByte() == 139 && f.ReadUnsignedByte() == 8)
        {
            int i = 0;
            byte gzipInputBuffer[] = new byte[65000];
            try
            {
                GZIPInputStream gzipinputstream = new GZIPInputStream(new ByteArrayInputStream(f.Buffer));
                do
                {
                    if(i == gzipInputBuffer.length)
                        throw new RuntimeException("buffer overflow!");
                    int k = gzipinputstream.read(gzipInputBuffer, i, gzipInputBuffer.length - i);
                    if(k == -1)
                        break;
                    i += k;
                } while(true);
            }
            catch(IOException _ex) { }
            byte buf[] = new byte[i];
            for(int j = 0; j < i; j++)
                buf[j] = gzipInputBuffer[j];

            return buf;
        }
        JagFile j = new JagFile(f.Buffer);
        for(int k = 0; k < j.datasize; k++)
        {
            byte e[] = new byte[j.filesize[k]];
            byte n[] = j.readfile(k, e);
            if(n != null)
                FileOperations.WriteFile(fpath+"/"+Main.CheckName(j.filename[k]), n);
        }

        return f.Buffer;
    }