Mercurial > 510Connectbot
annotate app/src/main/java/com/jcraft/jzlib/InflaterInputStream.java @ 465:7c8aebcc882a
request permissions if not already granted
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 19 Aug 2019 11:12:40 -0700 |
parents | d29cce60f393 |
children |
rev | line source |
---|---|
357
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
1 /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
2 /* |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
3 Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
4 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
5 Redistribution and use in source and binary forms, with or without |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
6 modification, are permitted provided that the following conditions are met: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
7 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
8 1. Redistributions of source code must retain the above copyright notice, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
9 this list of conditions and the following disclaimer. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
10 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
11 2. Redistributions in binary form must reproduce the above copyright |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
12 notice, this list of conditions and the following disclaimer in |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
13 the documentation and/or other materials provided with the distribution. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
14 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
15 3. The names of the authors may not be used to endorse or promote products |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
16 derived from this software without specific prior written permission. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
17 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
18 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
20 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
21 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
28 */ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
29 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
30 package com.jcraft.jzlib; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
31 import java.io.*; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
32 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
33 public class InflaterInputStream extends FilterInputStream { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
34 protected final Inflater inflater; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
35 protected byte[] buf; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
36 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
37 private boolean closed = false; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
38 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
39 private boolean eof = false; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
40 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
41 private boolean close_in = true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
42 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
43 protected static final int DEFAULT_BUFSIZE = 512; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
44 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
45 public InflaterInputStream(InputStream in) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
46 this(in, false); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
47 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
48 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
49 public InflaterInputStream(InputStream in, boolean nowrap) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
50 this(in, new Inflater(nowrap)); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
51 myinflater = true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
52 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
53 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
54 public InflaterInputStream(InputStream in, Inflater inflater) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
55 this(in, inflater, DEFAULT_BUFSIZE); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
56 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
57 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
58 public InflaterInputStream(InputStream in, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
59 Inflater inflater, int size) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
60 this(in, inflater, size, true); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
61 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
62 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
63 public InflaterInputStream(InputStream in, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
64 Inflater inflater, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
65 int size, boolean close_in) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
66 super(in); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
67 if (in == null || inflater == null) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
68 throw new NullPointerException(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
69 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
70 else if (size <= 0) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
71 throw new IllegalArgumentException("buffer size must be greater than 0"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
72 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
73 this.inflater = inflater; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
74 buf = new byte[size]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
75 this.close_in = close_in; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
76 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
77 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
78 protected boolean myinflater = false; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
79 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
80 private byte[] byte1 = new byte[1]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
81 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
82 public int read() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
83 if (closed) { throw new IOException("Stream closed"); } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
84 return read(byte1, 0, 1) == -1 ? -1 : byte1[0] & 0xff; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
85 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
86 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
87 public int read(byte[] b, int off, int len) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
88 if (closed) { throw new IOException("Stream closed"); } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
89 if (b == null) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
90 throw new NullPointerException(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
91 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
92 else if (off < 0 || len < 0 || len > b.length - off) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
93 throw new IndexOutOfBoundsException(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
94 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
95 else if (len == 0) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
96 return 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
97 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
98 else if (eof) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
99 return -1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
100 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
101 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
102 int n = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
103 inflater.setOutput(b, off, len); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
104 while(!eof) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
105 if(inflater.avail_in==0) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
106 fill(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
107 int err = inflater.inflate(JZlib.Z_NO_FLUSH); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
108 n += inflater.next_out_index - off; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
109 off = inflater.next_out_index; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
110 switch(err) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
111 case JZlib.Z_DATA_ERROR: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
112 throw new IOException(inflater.msg); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
113 case JZlib.Z_STREAM_END: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
114 case JZlib.Z_NEED_DICT: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
115 eof = true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
116 if(err == JZlib.Z_NEED_DICT) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
117 return -1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
118 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
119 default: |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
120 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
121 if(inflater.avail_out==0) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
122 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
123 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
124 return n; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
125 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
126 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
127 public int available() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
128 if (closed) { throw new IOException("Stream closed"); } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
129 if (eof) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
130 return 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
131 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
132 else { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
133 return 1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
134 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
135 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
136 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
137 private byte[] b = new byte[512]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
138 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
139 public long skip(long n) throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
140 if (n < 0) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
141 throw new IllegalArgumentException("negative skip length"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
142 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
143 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
144 if (closed) { throw new IOException("Stream closed"); } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
145 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
146 int max = (int)Math.min(n, Integer.MAX_VALUE); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
147 int total = 0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
148 while (total < max) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
149 int len = max - total; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
150 if (len > b.length) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
151 len = b.length; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
152 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
153 len = read(b, 0, len); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
154 if (len == -1) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
155 eof = true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
156 break; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
157 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
158 total += len; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
159 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
160 return total; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
161 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
162 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
163 public void close() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
164 if (!closed) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
165 if (myinflater) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
166 inflater.end(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
167 if(close_in) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
168 in.close(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
169 closed = true; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
170 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
171 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
172 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
173 protected void fill() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
174 if (closed) { throw new IOException("Stream closed"); } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
175 int len = in.read(buf, 0, buf.length); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
176 if (len == -1) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
177 if(inflater.istate.wrap == 0 && |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
178 !inflater.finished()){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
179 buf[0]=0; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
180 len=1; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
181 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
182 else if(inflater.istate.was != -1){ // in reading trailer |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
183 throw new IOException("footer is not found"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
184 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
185 else{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
186 throw new EOFException("Unexpected end of ZLIB input stream"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
187 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
188 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
189 inflater.setInput(buf, 0, len, true); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
190 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
191 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
192 public boolean markSupported() { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
193 return false; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
194 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
195 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
196 public synchronized void mark(int readlimit) { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
197 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
198 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
199 public synchronized void reset() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
200 throw new IOException("mark/reset not supported"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
201 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
202 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
203 public long getTotalIn() { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
204 return inflater.getTotalIn(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
205 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
206 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
207 public long getTotalOut() { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
208 return inflater.getTotalOut(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
209 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
210 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
211 public byte[] getAvailIn() { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
212 if(inflater.avail_in<=0) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
213 return null; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
214 byte[] tmp = new byte[inflater.avail_in]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
215 System.arraycopy(inflater.next_in, inflater.next_in_index, |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
216 tmp, 0, inflater.avail_in); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
217 return tmp; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
218 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
219 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
220 public void readHeader() throws IOException { |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
221 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
222 byte[] empty = "".getBytes(); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
223 inflater.setInput(empty, 0, 0, false); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
224 inflater.setOutput(empty, 0, 0); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
225 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
226 int err = inflater.inflate(JZlib.Z_NO_FLUSH); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
227 if(!inflater.istate.inParsingHeader()){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
228 return; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
229 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
230 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
231 byte[] b1 = new byte[1]; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
232 do{ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
233 int i = in.read(b1); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
234 if(i<=0) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
235 throw new IOException("no input"); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
236 inflater.setInput(b1); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
237 err = inflater.inflate(JZlib.Z_NO_FLUSH); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
238 if(err!=0/*Z_OK*/) |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
239 throw new IOException(inflater.msg); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
240 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
241 while(inflater.istate.inParsingHeader()); |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
242 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
243 |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
244 public Inflater getInflater(){ |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
245 return inflater; |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
246 } |
46c2115ae1c8
update jzlib to a21be20213d66eff15904d925e9b721956a01ef7
Carl Byington <carl@five-ten-sg.com>
parents:
diff
changeset
|
247 } |