[corlib] BufferedStream from reference sources
authorMarek Safar <marek.safar@gmail.com>
Thu, 19 Feb 2015 16:17:04 +0000 (17:17 +0100)
committerMarek Safar <marek.safar@gmail.com>
Thu, 19 Feb 2015 19:12:51 +0000 (20:12 +0100)
external/referencesource
mcs/class/corlib/System.IO/BufferedStream.cs [deleted file]
mcs/class/corlib/corlib.dll.sources

index 5ca0db753ca296eac802e839becd09780640f9e4..fb100a273aad88e69b895c687a1920a2ffa36fc5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5ca0db753ca296eac802e839becd09780640f9e4
+Subproject commit fb100a273aad88e69b895c687a1920a2ffa36fc5
diff --git a/mcs/class/corlib/System.IO/BufferedStream.cs b/mcs/class/corlib/System.IO/BufferedStream.cs
deleted file mode 100644 (file)
index e5b68c4..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-//
-// System.IO.BufferedStream
-//
-// Author:
-//   Matt Kimball (matt@kimball.net)
-//   Ville Palo <vi64pa@kolumbus.fi>
-//
-// Copyright (C) 2004 Novell (http://www.novell.com)
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Runtime.InteropServices;
-
-namespace System.IO {
-       [ComVisible (true)]
-       public sealed class BufferedStream : Stream {
-               Stream m_stream;
-               byte[] m_buffer;
-               int m_buffer_pos;
-               int m_buffer_read_ahead;
-               bool m_buffer_reading;
-               private bool disposed = false;
-
-               public BufferedStream (Stream stream) : this (stream, 4096) 
-               {
-               }
-
-               public BufferedStream (Stream stream, int bufferSize) 
-               {
-                       if (stream == null)
-                               throw new ArgumentNullException ("stream");
-                       // LAMESPEC: documented as < 0
-                       if (bufferSize <= 0)
-                               throw new ArgumentOutOfRangeException ("bufferSize", "<= 0");
-                       if (!stream.CanRead && !stream.CanWrite) {
-                               throw new ObjectDisposedException (
-                                       Locale.GetText ("Cannot access a closed Stream."));
-                       }
-
-                       m_stream = stream;
-                       m_buffer = new byte [bufferSize];
-               }
-
-               public override bool CanRead {
-                       get {
-                               return m_stream.CanRead;
-                       }
-               }
-
-               public override bool CanWrite {
-                       get {
-                               return m_stream.CanWrite;
-                       }
-               }
-
-               public override bool CanSeek {
-                       get {
-                               return m_stream.CanSeek;
-                       }
-               }
-
-               public override long Length {
-                       get {                           
-                               Flush ();
-                               return m_stream.Length;
-                       }
-               }
-               
-               public override long Position {
-                       get {
-                               CheckObjectDisposedException ();
-                               return m_stream.Position - m_buffer_read_ahead + m_buffer_pos;
-                       }
-
-                       set {
-                               if (value < Position && (Position - value <= m_buffer_pos) && m_buffer_reading) {
-                                       m_buffer_pos -= (int) (Position - value);
-                               }
-                               else if (value > Position && (value - Position < m_buffer_read_ahead - m_buffer_pos) && m_buffer_reading) {
-                                       m_buffer_pos += (int) (value - Position);
-                               }
-                               else {
-                                       Flush();
-                                       m_stream.Position = value;
-                               }
-                       }
-               }
-
-               protected override void Dispose (bool disposing)
-               {
-                       if (disposed)
-                               return;
-                       if (m_buffer != null)
-                               Flush();
-
-                       m_stream.Close();
-                       m_buffer = null;
-                       disposed = true;
-               }
-
-               public override void Flush ()
-               {
-                       CheckObjectDisposedException ();
-
-                       if (m_buffer_reading) {
-                               if (CanSeek)
-                                       m_stream.Position = Position;
-                       } else if (m_buffer_pos > 0) {
-                               m_stream.Write(m_buffer, 0, m_buffer_pos);
-                       }
-
-                       m_buffer_read_ahead = 0;
-                       m_buffer_pos = 0;
-               }
-
-               public override long Seek (long offset, SeekOrigin origin)
-               {
-                       CheckObjectDisposedException ();
-                       if (!CanSeek) {
-                               throw new NotSupportedException (
-                                       Locale.GetText ("Non seekable stream."));
-                       }
-                       Flush ();
-                       return m_stream.Seek (offset, origin);
-               }
-
-               public override void SetLength (long value)
-               {
-                       CheckObjectDisposedException ();
-
-                       if (value < 0)
-                               throw new ArgumentOutOfRangeException ("value must be positive");
-
-                       if (!m_stream.CanWrite && !m_stream.CanSeek)
-                               throw new NotSupportedException ("the stream cannot seek nor write.");
-
-                       if ((m_stream == null) || (!m_stream.CanRead && !m_stream.CanWrite))
-                               throw new IOException ("the stream is not open");
-                       
-                       m_stream.SetLength(value);
-                       if (Position > value)
-                               Position = value;
-               }
-
-               public override int ReadByte ()
-               {
-                       CheckObjectDisposedException ();
-                       
-                       if (!m_stream.CanRead) {
-                               throw new NotSupportedException (
-                                       Locale.GetText ("Cannot read from stream"));
-                       }
-
-                       if (!m_buffer_reading) {
-                               Flush ();
-                               m_buffer_reading = true;
-                       }
-
-                       if (1 <= m_buffer_read_ahead - m_buffer_pos) {
-                               return m_buffer [m_buffer_pos++];
-                       }
-                       else
-                       {
-                               if (m_buffer_pos >= m_buffer_read_ahead) {
-                                       m_buffer_pos = 0;
-                                       m_buffer_read_ahead = 0;
-                               }
-
-                               m_buffer_read_ahead = m_stream.Read (m_buffer, 0, m_buffer.Length);
-                               if (1 <= m_buffer_read_ahead) {
-                                       return m_buffer [m_buffer_pos++];
-                               } else {
-                                       return -1;
-                               }
-                       }
-               }
-
-               public override void WriteByte (byte value) 
-               {
-                       CheckObjectDisposedException ();
-                       if (!m_stream.CanWrite) {
-                               throw new NotSupportedException (
-                                       Locale.GetText ("Cannot write to stream"));
-                       }
-
-                       if (m_buffer_reading) {
-                               Flush ();
-                               m_buffer_reading = false;
-                       } 
-                       else
-                       // reordered to avoid possible integer overflow
-                       if (m_buffer_pos >= m_buffer.Length - 1) {
-                               Flush ();
-                       } 
-
-                       m_buffer [m_buffer_pos++] = value;
-               }
-
-               public override int Read ([In,Out] byte[] array, int offset, int count) 
-               {
-                       if (array == null)
-                               throw new ArgumentNullException ("array");
-                       CheckObjectDisposedException ();
-                       if (!m_stream.CanRead) {
-                               throw new NotSupportedException (
-                                       Locale.GetText ("Cannot read from stream"));
-                       }
-                       if (offset < 0)
-                               throw new ArgumentOutOfRangeException ("offset", "< 0");
-                       if (count < 0)
-                               throw new ArgumentOutOfRangeException ("count", "< 0");
-                       // re-ordered to avoid possible integer overflow
-                       if (array.Length - offset < count)
-                               throw new ArgumentException ("array.Length - offset < count");
-
-                       if (!m_buffer_reading) {
-                               Flush();
-                               m_buffer_reading = true;
-                       }
-
-                       if (count <= m_buffer_read_ahead - m_buffer_pos) {
-                               Buffer.BlockCopyInternal (m_buffer, m_buffer_pos, array, offset, count);
-
-                               m_buffer_pos += count;
-                               if (m_buffer_pos == m_buffer_read_ahead) {
-                                       m_buffer_pos = 0;
-                                       m_buffer_read_ahead = 0;
-                               }
-
-                               return count;
-                       }
-
-                       int ret = m_buffer_read_ahead - m_buffer_pos;
-                       Buffer.BlockCopyInternal (m_buffer, m_buffer_pos, array, offset, ret);
-                       m_buffer_pos = 0;
-                       m_buffer_read_ahead = 0;
-                       offset += ret;
-                       count -= ret;
-
-                       if (count >= m_buffer.Length) {
-                               ret += m_stream.Read (array, offset, count);
-                       } else {
-                               m_buffer_read_ahead = m_stream.Read (m_buffer, 0, m_buffer.Length);
-                               
-                               if (count < m_buffer_read_ahead) {
-                                       Buffer.BlockCopyInternal (m_buffer, 0, array, offset, count);
-                                       m_buffer_pos = count;
-                                       ret += count;
-                               } else {
-                                       Buffer.BlockCopyInternal (m_buffer, 0, array, offset, m_buffer_read_ahead);
-                                       ret += m_buffer_read_ahead;
-                                       m_buffer_read_ahead = 0;
-                               }
-                       }
-
-                       return ret;
-               }
-
-               public override void Write (byte[] array, int offset, int count)
-               {
-                       if (array == null)
-                               throw new ArgumentNullException ("array");
-                       CheckObjectDisposedException ();
-                       if (!m_stream.CanWrite) {
-                               throw new NotSupportedException (
-                                       Locale.GetText ("Cannot write to stream"));
-                       }
-                       if (offset < 0)
-                               throw new ArgumentOutOfRangeException ("offset", "< 0");
-                       if (count < 0)
-                               throw new ArgumentOutOfRangeException ("count", "< 0");
-                       // avoid possible integer overflow
-                       if (array.Length - offset < count)
-                               throw new ArgumentException ("array.Length - offset < count");
-
-                       if (m_buffer_reading) {
-                               Flush();
-                               m_buffer_reading = false;
-                       }
-
-                       // reordered to avoid possible integer overflow
-                       if (m_buffer_pos >= m_buffer.Length - count) {
-                               Flush ();
-                               m_stream.Write (array, offset, count);
-                       } 
-                       else {
-                               Buffer.BlockCopyInternal  (array, offset, m_buffer, m_buffer_pos, count);
-                               m_buffer_pos += count;
-                       }
-               }
-
-               private void CheckObjectDisposedException () 
-               {
-                       if (disposed) {
-                               throw new ObjectDisposedException ("BufferedStream", 
-                                       Locale.GetText ("Stream is closed"));
-                       }
-               }
-       }
-}
index 569ba245b4582e6ce02acf95564b4c25191f59cf..4b26ebaca5b41e04544cccb17d54ff429d21c620 100644 (file)
@@ -331,7 +331,6 @@ System.Globalization/TextInfo.cs
 System.Globalization/UnicodeCategory.cs
 System.IO/BinaryReader.cs
 System.IO/BinaryWriter.cs
-System.IO/BufferedStream.cs
 System.IO/Directory.cs
 System.IO/DirectoryInfo.cs
 System.IO/DirectoryNotFoundException.cs
@@ -1562,6 +1561,7 @@ ReferenceSources/EncodingTable.cs
 ../../../external/referencesource/mscorlib/system/globalization/umalquracalendar.cs
 
 ../../../external/referencesource/mscorlib/system/io/__error.cs
+../../../external/referencesource/mscorlib/system/io/bufferedstream.cs
 ../../../external/referencesource/mscorlib/system/io/memorystream.cs
 ../../../external/referencesource/mscorlib/system/io/stream.cs
 ../../../external/referencesource/mscorlib/system/io/streamreader.cs
@@ -1659,6 +1659,7 @@ ReferenceSources/EncodingTable.cs
 ../../../external/referencesource/mscorlib/system/threading/timeout.cs
 ../../../external/referencesource/mscorlib/system/threading/waithandlecannotbeopenedexception.cs
 
+../../../external/referencesource/mscorlib/system/threading/Tasks/BeginEndAwaitableAdapter.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/TaskFactory.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/TaskScheduler.cs
@@ -1675,4 +1676,6 @@ ReferenceSources/EncodingTable.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/TaskExceptionHolder.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/ConcurrentExclusiveSchedulerPair.cs
 ../../../external/referencesource/mscorlib/system/threading/Tasks/ProducerConsumerQueues.cs
+../../../external/referencesource/mscorlib/system/threading/Tasks/TaskToApm.cs
+