Mercurial > projects > dwt2
diff java/src/java/io/FileInputStream.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 | 2847134a5fc0 |
children |
line wrap: on
line diff
--- a/java/src/java/io/FileInputStream.d Wed Mar 18 12:10:17 2009 +0100 +++ b/java/src/java/io/FileInputStream.d Thu Mar 19 20:38:55 2009 +0100 @@ -7,15 +7,19 @@ import java.io.File; import java.io.InputStream; -import TangoFile = tango.io.device.File; -import tango.core.Exception; -import tango.text.convert.Format; +version(Tango){ + import TangoFile = tango.io.device.File; +} else { // Phobos +} public class FileInputStream : java.io.InputStream.InputStream { alias java.io.InputStream.InputStream.read read; - private TangoFile.File conduit; + version(Tango){ + private TangoFile.File conduit; + } else { // Phobos + } private ubyte[] buffer; private int buf_pos; private int buf_size; @@ -23,38 +27,51 @@ private bool eof; public this ( String name ){ - conduit = new TangoFile.File( name ); + version(Tango){ + conduit = new TangoFile.File( name ); + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + } buffer = new ubyte[]( BUFFER_SIZE ); } public this ( java.io.File.File file ){ implMissing( __FILE__, __LINE__ ); - conduit = new TangoFile.File( file.getAbsolutePath(), TangoFile.File.ReadExisting ); + version(Tango){ + conduit = new TangoFile.File( file.getAbsolutePath(), TangoFile.File.ReadExisting ); + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + } buffer = new ubyte[]( BUFFER_SIZE ); } public override int read(){ - if( eof ){ - return -1; - } - try{ - if( buf_pos == buf_size ){ - buf_pos = 0; - buf_size = conduit.input.read( buffer ); + version(Tango){ + if( eof ){ + return -1; } - if( buf_size <= 0 ){ + try{ + if( buf_pos == buf_size ){ + buf_pos = 0; + buf_size = conduit.input.read( buffer ); + } + if( buf_size <= 0 ){ + eof = true; + return -1; + } + assert( buf_pos < BUFFER_SIZE, Format( "{0} {1}", buf_pos, buf_size ) ); + assert( buf_size <= BUFFER_SIZE ); + int res = cast(int) buffer[ buf_pos ]; + buf_pos++; + return res; + } + catch( IOException e ){ eof = true; return -1; } - assert( buf_pos < BUFFER_SIZE, Format( "{0} {1}", buf_pos, buf_size ) ); - assert( buf_size <= BUFFER_SIZE ); - int res = cast(int) buffer[ buf_pos ]; - buf_pos++; - return res; - } - catch( IOException e ){ - eof = true; - return -1; + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + return 0; } } @@ -69,7 +86,11 @@ } public override void close(){ - conduit.close(); + version(Tango){ + conduit.close(); + } else { // Phobos + implMissing( __FILE__, __LINE__ ); + } } }