Mercurial > projects > dwt2
comparison java/src/java/util/zip/InflaterInputStream.d @ 21:9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 19 Mar 2009 20:38:55 +0100 |
parents | 735224fcc45f |
children |
comparison
equal
deleted
inserted
replaced
20:dccb717aa902 | 21:9b96950f2c3c |
---|---|
1 /** | 1 /** |
2 * Authors: Frank Benoit <keinfarbton@googlemail.com> | 2 * Authors: Frank Benoit <keinfarbton@googlemail.com> |
3 */ | 3 */ |
4 module java.util.zip.InflaterInputStream; | 4 module java.util.zip.InflaterInputStream; |
5 | 5 |
6 public import java.io.InputStream; | |
7 import java.lang.all; | 6 import java.lang.all; |
8 import tango.io.compress.ZlibStream; | 7 import java.io.InputStream; |
9 version(Windows){ | 8 version(Tango){ |
10 version(build){ | 9 import tango.io.compress.ZlibStream; |
11 pragma(link,"zlib"); | 10 import tango.io.device.Conduit; |
11 version(Windows){ | |
12 version(build){ | |
13 pragma(link,"zlib"); | |
14 } | |
12 } | 15 } |
16 } else { // Phobos | |
17 import std.zlib; | |
13 } | 18 } |
14 | 19 |
15 import tango.io.device.Conduit; | 20 version(Tango){ |
21 class InputStreamWrapper : tango.io.model.IConduit.InputStream { | |
16 | 22 |
17 class InputStreamWrapper : tango.io.model.IConduit.InputStream { | 23 java.io.InputStream.InputStream istr; |
18 | 24 |
19 java.io.InputStream.InputStream istr; | 25 this( java.io.InputStream.InputStream istr ){ |
26 this.istr = istr; | |
27 } | |
20 | 28 |
21 this( java.io.InputStream.InputStream istr ){ | 29 uint read (void[] dst){ |
22 this.istr = istr; | 30 int res = istr.read( cast(byte[])dst ); |
31 return res; | |
32 } | |
33 | |
34 tango.io.model.IConduit.IConduit conduit (){ | |
35 implMissing(__FILE__,__LINE__); | |
36 return null; | |
37 } | |
38 | |
39 void close (){ | |
40 istr.close(); | |
41 } | |
42 tango.io.model.IConduit.InputStream input (){ | |
43 implMissing(__FILE__,__LINE__); | |
44 return null; | |
45 } | |
46 long seek (long offset, Anchor anchor = Anchor.Begin){ | |
47 implMissing(__FILE__,__LINE__); | |
48 return 0; | |
49 } | |
50 void[] load (size_t max = -1){ | |
51 implMissing(__FILE__,__LINE__); | |
52 return null; | |
53 } | |
54 IOStream flush (){ | |
55 implMissing(__FILE__,__LINE__); | |
56 return null; | |
57 } | |
23 } | 58 } |
59 } else { // Phobos | |
60 } | |
24 | 61 |
25 uint read (void[] dst){ | |
26 int res = istr.read( cast(byte[])dst ); | |
27 return res; | |
28 } | |
29 | |
30 tango.io.model.IConduit.IConduit conduit (){ | |
31 implMissing(__FILE__,__LINE__); | |
32 return null; | |
33 } | |
34 | |
35 void close (){ | |
36 istr.close(); | |
37 } | |
38 tango.io.model.IConduit.InputStream input (){ | |
39 implMissing(__FILE__,__LINE__); | |
40 return null; | |
41 } | |
42 long seek (long offset, Anchor anchor = Anchor.Begin){ | |
43 implMissing(__FILE__,__LINE__); | |
44 return 0; | |
45 } | |
46 void[] load (size_t max = -1){ | |
47 implMissing(__FILE__,__LINE__); | |
48 return null; | |
49 } | |
50 IOStream flush (){ | |
51 implMissing(__FILE__,__LINE__); | |
52 return null; | |
53 } | |
54 } | |
55 | 62 |
56 public class InflaterInputStream : java.io.InputStream.InputStream { | 63 public class InflaterInputStream : java.io.InputStream.InputStream { |
57 | 64 |
58 alias java.io.InputStream.InputStream.read read; | 65 alias java.io.InputStream.InputStream.read read; |
59 alias java.io.InputStream.InputStream.skip skip; | 66 alias java.io.InputStream.InputStream.skip skip; |
65 | 72 |
66 protected byte[] buf; | 73 protected byte[] buf; |
67 protected int len; | 74 protected int len; |
68 package bool usesDefaultInflater = false; | 75 package bool usesDefaultInflater = false; |
69 | 76 |
70 ZlibInput tangoIstr; | 77 version(Tango){ |
78 ZlibInput tangoIstr; | |
79 } else { // Phobos | |
80 } | |
71 | 81 |
72 public this ( java.io.InputStream.InputStream istr ){ | 82 public this ( java.io.InputStream.InputStream istr ){ |
73 tangoIstr = new ZlibInput( new InputStreamWrapper(istr )); | 83 version(Tango){ |
84 tangoIstr = new ZlibInput( new InputStreamWrapper(istr )); | |
85 } else { // Phobos | |
86 implMissing( __FILE__, __LINE__ ); | |
87 } | |
74 } | 88 } |
75 | 89 |
76 public int read(){ | 90 public int read(){ |
77 ubyte[1] data; | 91 version(Tango){ |
78 uint res = tangoIstr.read( data ); | 92 ubyte[1] data; |
79 if( res !is 1 ){ | 93 uint res = tangoIstr.read( data ); |
80 return data[0] & 0xFF; | 94 if( res !is 1 ){ |
95 return data[0] & 0xFF; | |
96 } | |
97 return -1; | |
98 } else { // Phobos | |
99 implMissing( __FILE__, __LINE__ ); | |
100 return -1; | |
81 } | 101 } |
82 return -1; | |
83 } | 102 } |
84 | 103 |
85 public int read( byte[] b, int off, int len ){ | 104 public int read( byte[] b, int off, int len ){ |
86 implMissing( __FILE__, __LINE__ ); | 105 implMissing( __FILE__, __LINE__ ); |
87 return 0; | 106 return 0; |