view dwt/dwthelper/FileOutputStream.d @ 308:8d53428f9be0

Tango breaking change for new package tango.io.device
author Frank Benoit <benoit@tionex.de>
date Sun, 14 Sep 2008 19:58:20 +0200
parents 32a6819fef61
children 1ee938a6e02e
line wrap: on
line source

/**
 * Authors: Frank Benoit <keinfarbton@googlemail.com>
 */
module dwt.dwthelper.FileOutputStream;

public import dwt.dwthelper.File;
public import dwt.dwthelper.OutputStream;

import dwt.dwthelper.utils;

version(TANGOSVN){
import tango.io.device.FileConduit;
} else {
import tango.io.FileConduit;
}

public class FileOutputStream : dwt.dwthelper.OutputStream.OutputStream {

    alias dwt.dwthelper.OutputStream.OutputStream.write write;
    alias dwt.dwthelper.OutputStream.OutputStream.close close;
    FileConduit fc;
    
    public this ( String name ){
        fc = new FileConduit( name, FileConduit.WriteCreate );
    }

    public this ( String name, bool append ){
        fc = new FileConduit( name, append ? FileConduit.WriteAppending : FileConduit.WriteCreate );
    }

    public this ( dwt.dwthelper.File.File file ){
        this( file.toString );
    }

    public this ( dwt.dwthelper.File.File file, bool append ){
        this( file.toString, append );
    }

    public override void write( int b ){
        ubyte[1] a;
        a[0] = b & 0xFF;
        fc.write(a);
    }

    public override void close(){
        fc.close();
    }

    public void finalize(){
        implMissing( __FILE__, __LINE__ );
    }


}