public int doRead(byte[] buffer, int offset, int byteCount)
 {
     if (markpos < 0)
     {
         return(readInternal(buffer, offset, byteCount));
     }
     else
     {
         if (isDisabled())
         {
             return(stream.Read(buffer, offset, byteCount));
         }
         int c = readInternal(buffer, offset, byteCount);
         if (c > 0 && markpos >= 0)
         {
             markpos += c;
             if (markpos > marklimit)
             {
                 marklimit = 0;
                 markpos   = -1;
                 if (this.buffer != null && isDisabled())
                 {
                     this.buffer = null;
                 }
             }
         }
         return(c);
     }
 }
示例#2
0
 public static void copyStream(PeterO.Support.InputStream stream, Stream output)
 {
     byte[] buffer = new byte[8192];
     while (true)
     {
         int count = stream.Read(buffer, 0, buffer.Length);
         if (count < 0)
         {
             break;
         }
         output.Write(buffer, 0, count);
     }
 }
示例#3
0
 public static void skipToEnd(PeterO.Support.InputStream stream)
 {
     if (stream == null)
     {
         return;
     }
     while (true)
     {
         byte[] x = new byte[1024];
         try {
             int c = stream.Read(x, 0, x.Length);
             if (c < 0)
             {
                 break;
             }
         } catch (IOException) {
             break; // maybe this stream is already closed
         }
     }
 }