diff dwt/dwthelper/InflaterInputStream.d @ 132:e22f9b443521

Working on ControlExample, png loading makes problems
author Frank Benoit <benoit@tionex.de>
date Mon, 21 Jan 2008 15:39:59 +0100
parents 0c78fa47d476
children 116d23207a86
line wrap: on
line diff
--- a/dwt/dwthelper/InflaterInputStream.d	Mon Jan 21 15:39:26 2008 +0100
+++ b/dwt/dwthelper/InflaterInputStream.d	Mon Jan 21 15:39:59 2008 +0100
@@ -5,6 +5,34 @@
 
 public import dwt.dwthelper.InputStream;
 import dwt.dwthelper.utils;
+import tango.io.Stdout;
+
+class InputStreamWrapper : tango.io.model.IConduit.InputStream {
+
+    dwt.dwthelper.InputStream.InputStream istr;
+
+    this( dwt.dwthelper.InputStream.InputStream istr ){
+        this.istr = istr;
+    }
+
+    uint read (void[] dst){
+        int res = istr.read( cast(byte[])dst, 0, dst.length );
+        //Stdout.formatln( "read {}/{}", dst.length, res );
+        return res;
+    }
+
+    tango.io.model.IConduit.InputStream clear (){
+        return this;
+    }
+
+    tango.io.model.IConduit.IConduit conduit (){
+        return null;
+    }
+
+    void close (){
+        istr.close();
+    }
+}
 
 public class InflaterInputStream : dwt.dwthelper.InputStream.InputStream {
 
@@ -20,12 +48,19 @@
     protected int len;
     package bool usesDefaultInflater = false;
 
+    InputStreamWrapper tangoIstr;
+
     public this ( dwt.dwthelper.InputStream.InputStream istr ){
+        tangoIstr = new InputStreamWrapper(istr );
     }
 
     public int read(){
-        implMissing( __FILE__, __LINE__ );
-        return 0;
+        ubyte[1] data;
+        uint res = tangoIstr.read( data );
+        if( res !is tango.io.model.IConduit.IOStream.Eof ){
+            return data[0] & 0xFF;
+        }
+        return -1;
     }
 
     public int read( byte[] b, int off, int len ){