annotate base/src/java/util/zip/InflaterInputStream.d @ 110:5d01af878529

Updated to latest Tango.
author Jacob Carlborg <doob@me.com>
date Fri, 12 Nov 2010 13:16:02 +0100
parents e944a4cf537b
children 9f4c18c268b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /**
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Authors: Frank Benoit <keinfarbton@googlemail.com>
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 */
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 module java.util.zip.InflaterInputStream;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 import java.lang.all;
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
7 import java.io.InputStream;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
8 version(Tango){
107
e944a4cf537b Updated to dmd 1.063 and Tango trunk.
Jacob Carlborg <doob@me.com>
parents: 76
diff changeset
9 import tango.io.stream.Zlib;
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
10 import tango.io.device.Conduit;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
11 version(Windows){
76
f05e6e8b2f2d pragma libs
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
12 pragma(lib,"zlib.lib");
f05e6e8b2f2d pragma libs
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
13 }
f05e6e8b2f2d pragma libs
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
14 else{
f05e6e8b2f2d pragma libs
Frank Benoit <benoit@tionex.de>
parents: 27
diff changeset
15 pragma(lib,"zlib");
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 }
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
17 } else { // Phobos
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
18 import std.zlib;
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 }
8
2847134a5fc0 more tango abstraction
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
20
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
21 version(Tango){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
22 class InputStreamWrapper : tango.io.model.IConduit.InputStream {
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
24 java.io.InputStream.InputStream istr;
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
26 this( java.io.InputStream.InputStream istr ){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
27 this.istr = istr;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
28 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29
110
5d01af878529 Updated to latest Tango.
Jacob Carlborg <doob@me.com>
parents: 107
diff changeset
30 size_t read (void[] dst){
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
31 int res = istr.read( cast(byte[])dst );
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
32 return res;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
33 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
35 tango.io.model.IConduit.IConduit conduit (){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
36 implMissing(__FILE__,__LINE__);
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
37 return null;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
38 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
40 void close (){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
41 istr.close();
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
42 }
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
43 tango.io.model.IConduit.InputStream input (){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
44 implMissing(__FILE__,__LINE__);
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
45 return null;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
46 }
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
47 long seek (long offset, Anchor anchor = Anchor.Begin){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
48 implMissing(__FILE__,__LINE__);
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
49 return 0;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
50 }
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
51 void[] load (size_t max = -1){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
52 implMissing(__FILE__,__LINE__);
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
53 return null;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
54 }
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
55 IOStream flush (){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
56 implMissing(__FILE__,__LINE__);
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
57 return null;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
58 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 }
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
60 } else { // Phobos
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
63
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 public class InflaterInputStream : java.io.InputStream.InputStream {
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 alias java.io.InputStream.InputStream.read read;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 alias java.io.InputStream.InputStream.skip skip;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 alias java.io.InputStream.InputStream.available available;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 alias java.io.InputStream.InputStream.close close;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70 alias java.io.InputStream.InputStream.mark mark;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 alias java.io.InputStream.InputStream.reset reset;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 alias java.io.InputStream.InputStream.markSupported markSupported;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 protected byte[] buf;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 protected int len;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 package bool usesDefaultInflater = false;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
78 version(Tango){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
79 ZlibInput tangoIstr;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
80 } else { // Phobos
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
81 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 public this ( java.io.InputStream.InputStream istr ){
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
84 version(Tango){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
85 tangoIstr = new ZlibInput( new InputStreamWrapper(istr ));
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
86 } else { // Phobos
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
87 implMissing( __FILE__, __LINE__ );
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
88 }
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 public int read(){
21
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
92 version(Tango){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
93 ubyte[1] data;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
94 uint res = tangoIstr.read( data );
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
95 if( res !is 1 ){
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
96 return data[0] & 0xFF;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
97 }
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
98 return -1;
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
99 } else { // Phobos
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
100 implMissing( __FILE__, __LINE__ );
9b96950f2c3c the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents: 18
diff changeset
101 return -1;
0
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 public int read( byte[] b, int off, int len ){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 return 0;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 public int available(){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 return 0;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 public long skip( long n ){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 return 0L;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 public void close(){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 public void fill(){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 public bool markSupported(){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130 return false;
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 public synchronized void mark( int readlimit ){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 public synchronized void reset(){
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 implMissing( __FILE__, __LINE__ );
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 }
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141
6dd524f61e62 add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142