dotgnu-libs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-libs-commits] CVS: dotgnu-base/DotGNU/IO FileStream.cs,1.2,1.3 I


From: Peter Minten <address@hidden>
Subject: [Dotgnu-libs-commits] CVS: dotgnu-base/DotGNU/IO FileStream.cs,1.2,1.3 IStream.cs,1.2,1.3 Stream.cs,1.3,1.4
Date: Sat, 03 Aug 2002 07:13:58 -0400

Update of /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/IO
In directory subversions:/tmp/cvs-serv4727/DotGNU/IO

Modified Files:
        FileStream.cs IStream.cs Stream.cs 
Log Message:
Weekly update


Index: FileStream.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/IO/FileStream.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** FileStream.cs       28 Jul 2002 15:56:34 -0000      1.2
--- FileStream.cs       3 Aug 2002 11:13:55 -0000       1.3
***************
*** 27,31 ****
  using System.Net.Sockets;
  using System.Text;
! 
  
  
--- 27,31 ----
  using System.Net.Sockets;
  using System.Text;
! using DotGNU.IO;
  
  
***************
*** 42,60 ****
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public void Read (String buffer)
        {
!               Stream.Read(this, buffer);
!               return;
        }
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public void Read (String buffer, Encoding encoding)
        {
!               Stream.Read(this, buffer, encoding);
!               return;
        }
  
--- 42,60 ----
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public int Read (String buffer)
        {
!               return dgStream.Read(this, buffer);
        }
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public int Read (String buffer, Encoding encoding)
        {
!               return dgStream.Read(this, buffer, encoding);
        }
  
***************
*** 64,68 ****
        public void Write(String buffer)
        {
!               Stream.Write(this, buffer);
                return;
        }
--- 64,68 ----
        public void Write(String buffer)
        {
!               dgStream.Write(this, buffer);
                return;
        }
***************
*** 74,78 ****
        public void Write(String buffer, Encoding encoding)
        {
!               Stream.Write(this, buffer, encoding);
                return;
        }
--- 74,78 ----
        public void Write(String buffer, Encoding encoding)
        {
!               dgStream.Write(this, buffer, encoding);
                return;
        }
***************
*** 83,102 ****
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static Stream operator>> (System.IO.Stream a, byte[] b)
        {
!               a.Read(b, 0, b.Length);
!               return null;
        }
                                  
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>      
!       public static Stream operator>> (System.IO.Stream a, String b)
        {
!               DotGNU.IO.Stream.Read(a, b);
!               return null;
        }
        
--- 83,102 ----
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static long operator>> (System.IO.Stream a, byte[] b)
        {
!               return a.Read(b, 0, b.Length);
        }
                                  
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>      
!       public static long operator>> (System.IO.Stream a, String b)
        {
!               return dgStream.Read(a, b);
        }
        
***************
*** 104,123 ****
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static Stream operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return null;
        }
  
        /// <summary>Write operator for String.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static Stream operator<< (System.IO.Stream a, String b)
        {
!               DotGNU.IO.Stream.Write(a, b);
!               return null;
!       }         
!       
  }; //class FileStream
  
  }; //namespace DotGNU.IO
--- 104,126 ----
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static void operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return;
        }
  
        /// <summary>Write operator for String.</summary>
+       /// <returns>The number of bytes send.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static void operator<< (System.IO.Stream a, String b)
        {
!               dgStream.Write(a, b);
!               return;
!       }
! 
  }; //class FileStream
+ 
+ class dgFileStream : DotGNU.IO.FileStream {}; //Alias
  
  }; //namespace DotGNU.IO

Index: IStream.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/IO/IStream.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** IStream.cs  28 Jul 2002 15:56:34 -0000      1.2
--- IStream.cs  3 Aug 2002 11:13:55 -0000       1.3
***************
*** 31,42 ****
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
!       void Read (String buffer);
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       void Read (String buffer, Encoding encoding);
        
        /// <summary>Write method using unicode, 
--- 31,44 ----
        /// <summary>Read method using unicode, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
!       int Read (String buffer);
        
        /// <summary>Read method using the specified encoding, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       int Read (String buffer, Encoding encoding);
        
        /// <summary>Write method using unicode, 

Index: Stream.cs
===================================================================
RCS file: /cvsroot/dotgnu-libs/dotgnu-base/DotGNU/IO/Stream.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Stream.cs   28 Jul 2002 15:56:34 -0000      1.3
--- Stream.cs   3 Aug 2002 11:13:55 -0000       1.4
***************
*** 43,49 ****
        /// <param name="stream">The stream to work on.</param>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public static void Read (System.IO.Stream stream, String buffer)
        {
!               Read(stream, buffer, Encoding.Unicode);
        }
  
--- 43,49 ----
        /// <param name="stream">The stream to work on.</param>
        /// <param name="buffer">The buffer to place the data in.</param>
!       public static int Read (System.IO.Stream stream, String buffer)
        {
!               return Read(stream, buffer, Encoding.Unicode);
        }
  
***************
*** 53,57 ****
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public static void Read (System.IO.Stream stream, String buffer, 
                Encoding encoding)
        {
--- 53,57 ----
        /// <param name="buffer">The buffer to place the data in.</param>
        /// <param name="encoding">The encoding to use.</param>
!       public static int Read (System.IO.Stream stream, String buffer, 
                Encoding encoding)
        {
***************
*** 60,86 ****
                byte[] bbuf = new byte[1024]; //Read 1024 at a time
                char[] cbuf = new char[514]; //Stay on the safe side with size 
estimations
-               String tbuffer;         
                int charsread;
!               
                do
                {
                        int bytesreceived = stream.Read(bbuf, 0, bbuf.Length);
!                               
                        charsread = encoding.GetChars(bbuf, 0, bytesreceived, 
cbuf, 0);
!                       
                        tbuffer = new String(cbuf);
!               
                        tbuffer = tbuffer.Substring(0, charsread); //Cut off 
useless chars
!                       
!                       buffer += tbuffer;
!                       
                        if (bytesreceived < 1024)
!                               return;
!                       
                } while (true); //Infinite loop if it wasn't for that return 
statement
        }
  
        /// <summary>Write method using unicode, 
        ///   writes all data in the buffer.</summary>
        /// <param name="stream">The stream to work on.</param>
        /// <param name="buffer">The buffer to get the data from.</param>
--- 60,92 ----
                byte[] bbuf = new byte[1024]; //Read 1024 at a time
                char[] cbuf = new char[514]; //Stay on the safe side with size 
estimations
                int charsread;
!               int bytesread = 0;
!               String tbuffer;
! 
                do
                {
                        int bytesreceived = stream.Read(bbuf, 0, bbuf.Length);
! 
                        charsread = encoding.GetChars(bbuf, 0, bytesreceived, 
cbuf, 0);
! 
                        tbuffer = new String(cbuf);
! 
                        tbuffer = tbuffer.Substring(0, charsread); //Cut off 
useless chars
! 
!                       buffer = String.Concat(buffer,tbuffer);
! 
!                       bytesread += bytesreceived;
! 
                        if (bytesreceived < 1024)
!                               return bytesread;
! 
                } while (true); //Infinite loop if it wasn't for that return 
statement
+               
+               return 0; //Useless, but saves a warning
        }
  
        /// <summary>Write method using unicode, 
        ///   writes all data in the buffer.</summary>
+       /// <returns>The number of bytes send.</returns>
        /// <param name="stream">The stream to work on.</param>
        /// <param name="buffer">The buffer to get the data from.</param>
***************
*** 88,91 ****
--- 94,98 ----
        {
                Write(stream, buffer, Encoding.Unicode);
+               return;
        }
        
***************
*** 98,145 ****
                Encoding encoding)
        {
!               buffer = ""; //Clean buffer
! 
!               byte[] bbuf = new byte[1024]; //Read 1024 at a time
!               char[] cbuf = new char[514]; //Stay on the safe side with size 
estimations
!               int charsread;
!               String tbuffer;
  
!               do
                {
!                       int bytesreceived = stream.Read(bbuf, 0, bbuf.Length);
! 
!                       charsread = encoding.GetChars(bbuf, 0, bytesreceived, 
cbuf, 0);
! 
!                       tbuffer = new String(cbuf);
! 
!                       tbuffer = tbuffer.Substring(0, charsread); //Cut off 
useless chars
! 
!                       buffer += tbuffer;
! 
!                       if (bytesreceived < 1024)
!                               return;
! 
!               } while (true); //Infinite loop if it wasn't for that return 
statement
        }
                
        //Operators
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static Stream operator>> (System.IO.Stream a, byte[] b)
        {
!               a.Read(b, 0, b.Length);
!               return null;
        }
        
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static Stream operator>> (System.IO.Stream a, String b)
        {
!               Read(a, b);
!               return null;
        }
        
--- 105,156 ----
                Encoding encoding)
        {
!               int charssend = 0;
!               char[] cbuf = new char[510]; //Stay on the safe side with size 
estimations
!               byte[] bbuf = new byte[1024];
!               int charptr = 0;
!               int bytesencoded;
!               int bytessend;
  
!               while (true)
                {
!                       if ((buffer.Length - charptr) >= 510)
!                       {
!                               bytesencoded = encoding.GetBytes(buffer, 
charptr, 510, bbuf, 0);
!                               charptr += 510; //510 chars are encoded
!                       }
!                       else
!                       {       
!                               int foo = buffer.Length - charptr;
!                               bytesencoded = encoding.GetBytes(buffer, 
charptr, foo, bbuf, 0);
!                               charptr += foo;
!                       }
!                       
!                       stream.Write(bbuf, 0, bytesencoded);
!                       
!                       if (charptr == buffer.Length)
!                               return; //Write operation done, return.
!               }
        }
                
+ 
        //Operators
        
        /// <summary>Read operator for byte[], reads until b is full.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static int operator>> (System.IO.Stream a, byte[] b)
        {
!               return a.Read(b, 0, b.Length);
        }
        
        /// <summary>Read operator for String, 
        ///   reads until no more data is available.</summary>
+       /// <returns>The number of bytes read.</returns>
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to put the data in.</param>
!       public static int operator>> (System.IO.Stream a, String b)
        {
!               return Read(a, b);
        }
        
***************
*** 147,154 ****
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static Stream operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return null;
        }
  
--- 158,165 ----
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>
!       public static void operator<< (System.IO.Stream a, byte[] b)
        {
                a.Write(b, 0, b.Length);
!               return;
        }
  
***************
*** 156,166 ****
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static Stream operator<< (System.IO.Stream a, String b)
        {
!               DotGNU.IO.Stream.Write(a, b);
!               return null;
!       }        
        
  }; // class Stream
  
  }; // namespace DotGNU.IO
--- 167,179 ----
        /// <param name="a">The stream to work on.</param>
        /// <param name="b">The buffer to get the data from.</param>    
!       public static void operator<< (System.IO.Stream a, String b)
        {
!               Stream.Write(a, b);
!               return;
!       }
        
  }; // class Stream
+ 
+ class dgStream : DotGNU.IO.Stream {}; //Alias
  
  }; // namespace DotGNU.IO




reply via email to

[Prev in Thread] Current Thread [Next in Thread]