Mercurial > projects > dwt-win
comparison dwt/dwthelper/InflaterInputStream.d @ 248:d10ff1f47f84
Add: version TANGOSVN
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 16:42:54 +0200 |
parents | 5406a8f6526d |
children | f6169caa2e05 |
comparison
equal
deleted
inserted
replaced
242:32a6819fef61 | 248:d10ff1f47f84 |
---|---|
3 */ | 3 */ |
4 module dwt.dwthelper.InflaterInputStream; | 4 module dwt.dwthelper.InflaterInputStream; |
5 | 5 |
6 public import dwt.dwthelper.InputStream; | 6 public import dwt.dwthelper.InputStream; |
7 import dwt.dwthelper.utils; | 7 import dwt.dwthelper.utils; |
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 } | |
8 | 44 |
9 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream { | 45 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream { |
10 | 46 |
11 alias dwt.dwthelper.InputStream.InputStream.read read; | 47 alias dwt.dwthelper.InputStream.InputStream.read read; |
12 alias dwt.dwthelper.InputStream.InputStream.skip skip; | 48 alias dwt.dwthelper.InputStream.InputStream.skip skip; |
18 | 54 |
19 protected byte[] buf; | 55 protected byte[] buf; |
20 protected int len; | 56 protected int len; |
21 package bool usesDefaultInflater = false; | 57 package bool usesDefaultInflater = false; |
22 | 58 |
59 ZlibInput tangoIstr; | |
60 | |
23 public this ( dwt.dwthelper.InputStream.InputStream istr ){ | 61 public this ( dwt.dwthelper.InputStream.InputStream istr ){ |
62 tangoIstr = new ZlibInput( new InputStreamWrapper(istr )); | |
24 } | 63 } |
25 | 64 |
26 public int read(){ | 65 public int read(){ |
27 implMissing( __FILE__, __LINE__ ); | 66 ubyte[1] data; |
28 return 0; | 67 uint res = tangoIstr.read( data ); |
68 if( res !is 1 ){ | |
69 return data[0] & 0xFF; | |
70 } | |
71 return -1; | |
29 } | 72 } |
30 | 73 |
31 public int read( byte[] b, int off, int len ){ | 74 public int read( byte[] b, int off, int len ){ |
32 implMissing( __FILE__, __LINE__ ); | 75 implMissing( __FILE__, __LINE__ ); |
33 return 0; | 76 return 0; |