public override int Read(byte[] buffer, int offset, int count)
{
int pos = offset;
try
{
int end = offset + count;
while (pos < end)
{
int b = ReadByte();
if (b == -1) break;
buffer[pos++] = (byte) b;
}
}
catch (IOException)
{
if (pos == offset) throw;
}
return pos - offset;
}