Esempio n. 1
0
        /// <summary>Copy all bytes remaining on the input stream into this buffer.</summary>
        /// <remarks>Copy all bytes remaining on the input stream into this buffer.</remarks>
        /// <param name="in">the stream to read from, until EOF is reached.</param>
        /// <exception cref="System.IO.IOException">
        /// an error occurred reading from the input stream, or while
        /// writing to a local temporary file.
        /// </exception>
        public virtual void Copy(InputStream @in)
        {
            if (blocks != null)
            {
                for (; ;)
                {
                    TemporaryBuffer.Block s = Last();
                    if (s.IsFull())
                    {
                        if (ReachedInCoreLimit())
                        {
                            break;
                        }
                        s = new TemporaryBuffer.Block();
                        blocks.AddItem(s);
                    }
                    int n = @in.Read(s.buffer, s.count, s.buffer.Length - s.count);
                    if (n < 1)
                    {
                        return;
                    }
                    s.count += n;
                }
            }
            byte[] tmp = new byte[TemporaryBuffer.Block.SZ];
            int    n_1;

            while ((n_1 = @in.Read(tmp)) > 0)
            {
                overflow.Write(tmp, 0, n_1);
            }
        }
Esempio n. 2
0
 /// <exception cref="System.IO.IOException"></exception>
 public override void Write(byte[] b, int off, int len)
 {
     if (overflow == null)
     {
         while (len > 0)
         {
             TemporaryBuffer.Block s = Last();
             if (s.IsFull())
             {
                 if (ReachedInCoreLimit())
                 {
                     break;
                 }
                 s = new TemporaryBuffer.Block();
                 blocks.AddItem(s);
             }
             int n = Math.Min(s.buffer.Length - s.count, len);
             System.Array.Copy(b, off, s.buffer, s.count, n);
             s.count += n;
             len     -= n;
             off     += n;
         }
     }
     if (len > 0)
     {
         overflow.Write(b, off, len);
     }
 }
Esempio n. 3
0
 /// <exception cref="System.IO.IOException"></exception>
 public override void Write(int b)
 {
     if (overflow != null)
     {
         overflow.Write(b);
         return;
     }
     TemporaryBuffer.Block s = Last();
     if (s.IsFull())
     {
         if (ReachedInCoreLimit())
         {
             overflow.Write(b);
             return;
         }
         s = new TemporaryBuffer.Block();
         blocks.AddItem(s);
     }
     s.buffer[s.count++] = unchecked ((byte)b);
 }