2007-04-18 Jeffrey Stedfast <fejj@novell.com>
[mono.git] / mcs / class / corlib / System / CStreamReader.cs
index 69ea50c3767f8f7d9985e201c0d75dbb60ed4854..420554f4a67f32b51928b954d14e183eb64710b6 100644 (file)
@@ -35,9 +35,12 @@ using System.Runtime.InteropServices;
 
 namespace System.IO {
        class CStreamReader : StreamReader {
+               TermInfoDriver driver;
+
                public CStreamReader(Stream stream, Encoding encoding)
                        : base (stream, encoding)
                {
+                       driver = (TermInfoDriver) ConsoleDriver.driver;
                }
 
                public override int Peek ()
@@ -61,37 +64,30 @@ namespace System.IO {
                        return(-1);
                }
 
-               public override int Read ([In, Out] char [] dest_buffer, int index, int count)
+               public override int Read ([In, Out] char [] dest, int index, int count)
                {
-                       if (dest_buffer == null)
-                               throw new ArgumentNullException ("dest_buffer");
+                       if (dest == null)
+                               throw new ArgumentNullException ("dest");
                        if (index < 0)
                                throw new ArgumentOutOfRangeException ("index", "< 0");
                        if (count < 0)
                                throw new ArgumentOutOfRangeException ("count", "< 0");
                        // ordered to avoid possible integer overflow
-                       if (index > dest_buffer.Length - count)
-                               throw new ArgumentException ("index + count > dest_buffer.Length");
-
-                       int chars_read = 0;
-                       while (count > 0) {
-                               int c = Read ();
-                               if (c < 0)
-                                       break;
-                               chars_read++;
-                               count--;
+                       if (index > dest.Length - count)
+                               throw new ArgumentException ("index + count > dest.Length");
 
-                               dest_buffer [index] = (char) c;
-                               //if (CheckEOL (dest_buffer [index++]))
-                               //      return chars_read;
+                       try {
+                               return driver.Read (dest, index, count);
+                       } catch (IOException) {
                        }
-                       return chars_read;
+
+                       return 0;
                }
 
                public override string ReadLine ()
                {
                        try {
-                               return ConsoleDriver.driver.ReadLine ();
+                               return driver.ReadLine ();
                        } catch (IOException) {
                        }