1 /**
2  * Authors: Frank Benoit <keinfarbton@googlemail.com>
3  */
4 module java.util.zip.InflaterInputStream;
5 
6 import java.lang.all;
7 import java.io.InputStream;
8 version(Tango){
9     import tango.io.stream.Zlib;
10     import tango.io.device.Conduit;
11     version(Windows){
12         pragma(lib,"zlib.lib");
13     }
14     else{
15         pragma(lib,"zlib");
16     }
17 } else { // Phobos
18     import std.zlib;
19 }
20 
21 version(Tango){
22     class InputStreamWrapper : tango.io.model.IConduit.InputStream {
23 
24         java.io.InputStream.InputStream istr;
25 
26         this( java.io.InputStream.InputStream istr ){
27             this.istr = istr;
28         }
29 
30         ptrdiff_t read (void[] dst){
31             int res = istr.read( cast(byte[])dst );
32             return res;
33         }
34 
35         tango.io.model.IConduit.IConduit conduit (){
36             implMissing(__FILE__,__LINE__);
37             return null;
38         }
39 
40         void close (){
41             istr.close();
42         }
43         tango.io.model.IConduit.InputStream input (){
44             implMissing(__FILE__,__LINE__);
45             return null;
46         }
47         long seek (long offset, Anchor anchor = Anchor.Begin){
48             implMissing(__FILE__,__LINE__);
49             return 0;
50         }
51         void[] load (ptrdiff_t max = -1){
52             implMissing(__FILE__,__LINE__);
53             return null;
54         }
55         IOStream flush (){
56             implMissing(__FILE__,__LINE__);
57             return null;
58         }
59     }
60 } else { // Phobos
61 }
62 
63 
64 public class InflaterInputStream : java.io.InputStream.InputStream {
65 
66     alias java.io.InputStream.InputStream.read read;
67     alias java.io.InputStream.InputStream.skip skip;
68     alias java.io.InputStream.InputStream.available available;
69     alias java.io.InputStream.InputStream.close close;
70     alias java.io.InputStream.InputStream.mark mark;
71     alias java.io.InputStream.InputStream.reset reset;
72     alias java.io.InputStream.InputStream.markSupported markSupported;
73 
74     protected byte[] buf;
75     protected int len;
76     package bool usesDefaultInflater = false;
77 
78     version(Tango){
79         ZlibInput tangoIstr;
80     } else { // Phobos
81     }
82 
83     public this ( java.io.InputStream.InputStream istr ){
84         version(Tango){
85             tangoIstr = new ZlibInput( new InputStreamWrapper(istr ));
86         } else { // Phobos
87             implMissingInPhobos();
88         }
89     }
90 
91     override
92     public int read(){
93         version(Tango){
94             ubyte[1] data;
95             uint res = tangoIstr.read( data );
96             if( res !is 1 ){
97                 return data[0] & 0xFF;
98             }
99             return -1;
100         } else { // Phobos
101             implMissingInPhobos();
102             return -1;
103         }
104     }
105 
106     override
107     public ptrdiff_t read( byte[] b, ptrdiff_t off, ptrdiff_t len ){
108         implMissing( __FILE__, __LINE__ );
109         return 0;
110     }
111 
112     override
113     public ptrdiff_t available(){
114         implMissing( __FILE__, __LINE__ );
115         return 0;
116     }
117 
118     override
119     public long skip( long n ){
120         implMissing( __FILE__, __LINE__ );
121         return 0L;
122     }
123 
124     override
125     public void close(){
126         implMissing( __FILE__, __LINE__ );
127     }
128 
129     public void fill(){
130         implMissing( __FILE__, __LINE__ );
131     }
132 
133     override
134     public bool markSupported(){
135         implMissing( __FILE__, __LINE__ );
136         return false;
137     }
138 
139     override
140     public synchronized void mark( int readlimit ){
141         implMissing( __FILE__, __LINE__ );
142     }
143 
144     override
145     public synchronized void reset(){
146         implMissing( __FILE__, __LINE__ );
147     }
148 }
149 
150