That stream reader should support read and peak (similar to
http://msdn.microsoft.com/en-us/library/system.io.streamreader.peek.aspx).
It will be useful in resumable upload where we read bytes into a buffer and
then want to figure out if is end of stream, so we read an additional cached
byte
BEFORE:
int len = 0;
// read bytes form the stream to lastMediaRequest byte array
while (true)
{
len = stream.Read(lastMediaRequest, lastMediaLength(int)Math.Min(BufferSize, ChunkSize - lastMediaLength));
lastMediaLength += len;
if (len == 0) break;
}
// check if there is still data to read from stream, and cache the first byte
in catchedByte
if (0 == stream.Read(cachedByte, 0, 1))
...
AFTER:
int bytesRead;
bool eos = false;
using (var reader = new BinaryStreamReader(stream, ChunkSize))
{
bytesRead = reader.Read();
eos = reader.Peek() == -1;
}
Original issue reported on code.google.com by pele...@google.com on 17 Apr 2013 at 3:18
Original issue reported on code.google.com by
pele...@google.com
on 17 Apr 2013 at 3:18