Mercurial > projects > dwt-win
annotate dwt/dwthelper/InflaterInputStream.d @ 251:f6169caa2e05
Fix: add pragma link for zlib on windows.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 17:34:59 +0200 |
parents | d10ff1f47f84 |
children | a63e2cd5485e |
rev | line source |
---|---|
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; | |
251
f6169caa2e05
Fix: add pragma link for zlib on windows.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
10 version(Windows){ |
f6169caa2e05
Fix: add pragma link for zlib on windows.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
11 version(build){ |
f6169caa2e05
Fix: add pragma link for zlib on windows.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
12 pragma(link,"zlib"); |
f6169caa2e05
Fix: add pragma link for zlib on windows.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
13 } |
f6169caa2e05
Fix: add pragma link for zlib on windows.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
14 } |
248 | 15 version(TANGOSVN) { |
16 import tango.io.Conduit; | |
17 } | |
18 class InputStreamWrapper : tango.io.model.IConduit.InputStream { | |
19 | |
20 dwt.dwthelper.InputStream.InputStream istr; | |
21 | |
22 this( dwt.dwthelper.InputStream.InputStream istr ){ | |
23 this.istr = istr; | |
24 } | |
25 | |
26 uint read (void[] dst){ | |
27 int res = istr.read( cast(byte[])dst ); | |
28 return res; | |
29 } | |
30 version(TANGOSVN) { | |
31 void[] load (void[] dst = null) { | |
32 return Conduit.load (this, dst); | |
33 } | |
34 } | |
35 | |
36 | |
37 tango.io.model.IConduit.InputStream clear (){ | |
38 return this; | |
39 } | |
40 | |
41 tango.io.model.IConduit.IConduit conduit (){ | |
42 return null; | |
43 } | |
44 | |
45 void close (){ | |
46 istr.close(); | |
47 } | |
48 } | |
0 | 49 |
50 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream { | |
51 | |
52 alias dwt.dwthelper.InputStream.InputStream.read read; | |
53 alias dwt.dwthelper.InputStream.InputStream.skip skip; | |
54 alias dwt.dwthelper.InputStream.InputStream.available available; | |
55 alias dwt.dwthelper.InputStream.InputStream.close close; | |
56 alias dwt.dwthelper.InputStream.InputStream.mark mark; | |
57 alias dwt.dwthelper.InputStream.InputStream.reset reset; | |
58 alias dwt.dwthelper.InputStream.InputStream.markSupported markSupported; | |
59 | |
60 protected byte[] buf; | |
61 protected int len; | |
62 package bool usesDefaultInflater = false; | |
63 | |
248 | 64 ZlibInput tangoIstr; |
65 | |
0 | 66 public this ( dwt.dwthelper.InputStream.InputStream istr ){ |
248 | 67 tangoIstr = new ZlibInput( new InputStreamWrapper(istr )); |
0 | 68 } |
69 | |
70 public int read(){ | |
248 | 71 ubyte[1] data; |
72 uint res = tangoIstr.read( data ); | |
73 if( res !is 1 ){ | |
74 return data[0] & 0xFF; | |
75 } | |
76 return -1; | |
0 | 77 } |
78 | |
79 public int read( byte[] b, int off, int len ){ | |
80 implMissing( __FILE__, __LINE__ ); | |
81 return 0; | |
82 } | |
83 | |
84 public int available(){ | |
85 implMissing( __FILE__, __LINE__ ); | |
86 return 0; | |
87 } | |
88 | |
89 public long skip( long n ){ | |
90 implMissing( __FILE__, __LINE__ ); | |
91 return 0L; | |
92 } | |
93 | |
94 public void close(){ | |
95 implMissing( __FILE__, __LINE__ ); | |
96 } | |
97 | |
98 public void fill(){ | |
99 implMissing( __FILE__, __LINE__ ); | |
100 } | |
101 | |
102 public bool markSupported(){ | |
103 implMissing( __FILE__, __LINE__ ); | |
104 return false; | |
105 } | |
106 | |
107 public synchronized void mark( int readlimit ){ | |
108 implMissing( __FILE__, __LINE__ ); | |
109 } | |
110 | |
111 public synchronized void reset(){ | |
112 implMissing( __FILE__, __LINE__ ); | |
113 } | |
114 } | |
115 | |
116 |