Changeset 257:cc1d3de0e80b

Show
Ignore:
Timestamp:
06/24/08 16:12:18 (3 months ago)
Author:
Frank Benoit <benoit@tionex.de>
Children:

258:0389eeb717f8 259:c0d810de7093

branch:
default
Message:

Fix: make ImageLoader?.save work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/ByteArrayOutputStream.d

    r238 r257  
    66public import dwt.dwthelper.OutputStream; 
    77import dwt.dwthelper.utils; 
     8import tango.io.GrowBuffer; 
    89 
    910public class ByteArrayOutputStream : dwt.dwthelper.OutputStream.OutputStream { 
    1011 
    11     alias dwt.dwthelper.OutputStream.OutputStream.write write
     12    protected GrowBuffer buffer
    1213 
    13     protected byte[] buf; 
    14     protected int count; 
    1514    public this (){ 
     15        buffer = new GrowBuffer(); 
    1616    } 
    1717 
    1818    public this ( int par_size ){ 
     19        buffer = new GrowBuffer(par_size); 
    1920    } 
    2021 
    21     public synchronized void write( int b ){ 
    22         implMissing( __FILE__, __LINE__ ); 
     22    public synchronized override void write( int b ){ 
     23        byte[1] a; 
     24        a[0] = b & 0xFF; 
     25        buffer.append(a); 
    2326    } 
    2427 
    25     public synchronized void write( byte[] b, int off, int len ){ 
    26         implMissing( __FILE__, __LINE__ ); 
     28    public synchronized override void write( byte[] b, int off, int len ){ 
     29        buffer.append( b[ off .. off + len ]); 
     30    } 
     31 
     32    public synchronized override void write( byte[] b ){ 
     33        buffer.append( b ); 
    2734    } 
    2835 
     
    3643 
    3744    public synchronized byte[] toByteArray(){ 
    38         implMissing( __FILE__, __LINE__ ); 
    39         return null; 
     45        return cast(byte[])buffer.slice(); 
    4046    } 
    4147 
     
    6369        implMissing( __FILE__, __LINE__ ); 
    6470    } 
    65  
    66  
    6771} 
    6872 
  • dwt/dwthelper/FileOutputStream.d

    r238 r257  
    99import dwt.dwthelper.utils; 
    1010 
     11import tango.io.FileConduit; 
     12 
    1113public class FileOutputStream : dwt.dwthelper.OutputStream.OutputStream { 
    1214 
    1315    alias dwt.dwthelper.OutputStream.OutputStream.write write; 
    1416    alias dwt.dwthelper.OutputStream.OutputStream.close close; 
    15  
     17    FileConduit fc; 
     18     
    1619    public this ( String name ){ 
    17         implMissing( __FILE__, __LINE__ ); 
     20        fc = new FileConduit( name, FileConduit.WriteCreate ); 
    1821    } 
    1922 
    2023    public this ( String name, bool append ){ 
    21         implMissing( __FILE__, __LINE__ ); 
     24        fc = new FileConduit( name, append ? FileConduit.WriteAppending : FileConduit.WriteCreate ); 
    2225    } 
    2326 
    2427    public this ( dwt.dwthelper.File.File file ){ 
    25         implMissing( __FILE__, __LINE__ ); 
     28        this( file.toString ); 
    2629    } 
    2730 
    2831    public this ( dwt.dwthelper.File.File file, bool append ){ 
    29         implMissing( __FILE__, __LINE__ ); 
     32        this( file.toString, append ); 
    3033    } 
    3134 
    32     public void write( int b ){ 
    33         implMissing( __FILE__, __LINE__ ); 
     35    public override void write( int b ){ 
     36        ubyte[1] a; 
     37        a[0] = b & 0xFF; 
     38        fc.write(a); 
    3439    } 
    3540 
    36     public void write( byte[] b ){ 
    37         implMissing( __FILE__, __LINE__ ); 
    38     } 
    39  
    40     public void write( byte[] b, int off, int len ){ 
    41         implMissing( __FILE__, __LINE__ ); 
    42     } 
    43  
    44     public void close(){ 
    45         implMissing( __FILE__, __LINE__ ); 
     41    public override void close(){ 
     42        fc.close(); 
    4643    } 
    4744 
  • dwt/dwthelper/OutputStream.d

    r238 r257  
    55 
    66import dwt.dwthelper.utils; 
    7 static import tango.io.model.IConduit; 
    87 
    98public abstract class OutputStream { 
    109 
    11     private tango.io.model.IConduit.OutputStream ostr; 
    12  
    1310    public this(){ 
    14     } 
    15  
    16     protected this( tango.io.model.IConduit.OutputStream aOutStream) { 
    17         this.ostr = aOutStream; 
    18     } 
    19  
    20     protected this(OutputStream rhs) { 
    21         ostr = rhs.ostr; 
    2211    } 
    2312 
     
    2514 
    2615    public void write( byte[] b ){ 
    27         ostr.write(b); 
    28     } 
    29  
    30     public void write(String c) { 
    31         ostr.write(c); 
     16        foreach( bv; b ){ 
     17            write(bv); 
     18        } 
    3219    } 
    3320 
    3421    public void write( byte[] b, int off, int len ){ 
    35         implMissing( __FILE__, __LINE__ ); 
     22        write(b[off .. off+len]); 
    3623    } 
    3724 
    3825    public void flush(){ 
    39         ostr.flush(); 
    4026    } 
    4127 
    4228    public void close(){ 
    43         ostr.flush(); 
    44         implMissing( __FILE__, __LINE__ ); 
    4529    } 
    46  
    47  
    4830} 
    4931