0
|
1 /**
|
|
2 * Authors: Frank Benoit <keinfarbton@googlemail.com>
|
|
3 */
|
|
4 module dwt.dwthelper.InflaterInputStream;
|
|
5
|
|
6 public import dwt.dwthelper.InputStream;
|
|
7 import dwt.dwthelper.utils;
|
248
|
8 import tango.io.Stdout;
|
|
9 import tango.io.compress.ZlibStream;
|
|
10 version(TANGOSVN) {
|
|
11 import tango.io.Conduit;
|
|
12 }
|
|
13 class InputStreamWrapper : tango.io.model.IConduit.InputStream {
|
|
14
|
|
15 dwt.dwthelper.InputStream.InputStream istr;
|
|
16
|
|
17 this( dwt.dwthelper.InputStream.InputStream istr ){
|
|
18 this.istr = istr;
|
|
19 }
|
|
20
|
|
21 uint read (void[] dst){
|
|
22 int res = istr.read( cast(byte[])dst );
|
|
23 return res;
|
|
24 }
|
|
25 version(TANGOSVN) {
|
|
26 void[] load (void[] dst = null) {
|
|
27 return Conduit.load (this, dst);
|
|
28 }
|
|
29 }
|
|
30
|
|
31
|
|
32 tango.io.model.IConduit.InputStream clear (){
|
|
33 return this;
|
|
34 }
|
|
35
|
|
36 tango.io.model.IConduit.IConduit conduit (){
|
|
37 return null;
|
|
38 }
|
|
39
|
|
40 void close (){
|
|
41 istr.close();
|
|
42 }
|
|
43 }
|
0
|
44
|
|
45 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream {
|
|
46
|
|
47 alias dwt.dwthelper.InputStream.InputStream.read read;
|
|
48 alias dwt.dwthelper.InputStream.InputStream.skip skip;
|
|
49 alias dwt.dwthelper.InputStream.InputStream.available available;
|
|
50 alias dwt.dwthelper.InputStream.InputStream.close close;
|
|
51 alias dwt.dwthelper.InputStream.InputStream.mark mark;
|
|
52 alias dwt.dwthelper.InputStream.InputStream.reset reset;
|
|
53 alias dwt.dwthelper.InputStream.InputStream.markSupported markSupported;
|
|
54
|
|
55 protected byte[] buf;
|
|
56 protected int len;
|
|
57 package bool usesDefaultInflater = false;
|
|
58
|
248
|
59 ZlibInput tangoIstr;
|
|
60
|
0
|
61 public this ( dwt.dwthelper.InputStream.InputStream istr ){
|
248
|
62 tangoIstr = new ZlibInput( new InputStreamWrapper(istr ));
|
0
|
63 }
|
|
64
|
|
65 public int read(){
|
248
|
66 ubyte[1] data;
|
|
67 uint res = tangoIstr.read( data );
|
|
68 if( res !is 1 ){
|
|
69 return data[0] & 0xFF;
|
|
70 }
|
|
71 return -1;
|
0
|
72 }
|
|
73
|
|
74 public int read( byte[] b, int off, int len ){
|
|
75 implMissing( __FILE__, __LINE__ );
|
|
76 return 0;
|
|
77 }
|
|
78
|
|
79 public int available(){
|
|
80 implMissing( __FILE__, __LINE__ );
|
|
81 return 0;
|
|
82 }
|
|
83
|
|
84 public long skip( long n ){
|
|
85 implMissing( __FILE__, __LINE__ );
|
|
86 return 0L;
|
|
87 }
|
|
88
|
|
89 public void close(){
|
|
90 implMissing( __FILE__, __LINE__ );
|
|
91 }
|
|
92
|
|
93 public void fill(){
|
|
94 implMissing( __FILE__, __LINE__ );
|
|
95 }
|
|
96
|
|
97 public bool markSupported(){
|
|
98 implMissing( __FILE__, __LINE__ );
|
|
99 return false;
|
|
100 }
|
|
101
|
|
102 public synchronized void mark( int readlimit ){
|
|
103 implMissing( __FILE__, __LINE__ );
|
|
104 }
|
|
105
|
|
106 public synchronized void reset(){
|
|
107 implMissing( __FILE__, __LINE__ );
|
|
108 }
|
|
109 }
|
|
110
|
|
111
|