bugDotGNU Portable.NET - Bugs: bug #14339, BinaryReader doesn't read...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #14339: BinaryReader doesn't read specified amount of bytes

Submitted by:  Peter Flaig <fliege>
Submitted on:  Tue 30 Aug 2005 12:00:58 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 31 Aug 2005 09:24:41 AM UTC, comment #1:

Fixed in CVS 31.08.05, thanks!

Deryk Robosson <drobosson>
Project Member
Tue 30 Aug 2005 12:00:58 PM UTC, original submission:

The method 'byte[] ReadBytes(int count)' of System.IO.BinaryReader doesn't read the specified amount of bytes although the end of the stream isn't reached.

In MS.NET there is a while loop to read the specified amount of bytes until the end of the stream is reached.

For DotGNU the method should look like this:
public virtual byte[] ReadBytes(int count)
{
byte[] buffer;
int result;
if(count < 0)
{
throw new ArgumentOutOfRangeException("count", "ArgRange_NonNegative"));
}
buffer = new byte [count];

do
{
int num2 = Read(buffer, result, count);
if (num2 == 0)
{
break;
}
result += num2;
count -= num2;
}
while (count > 0);

if (result != buffer.Length)
{
byte[] newBuffer = new byte [result];
Array.Copy(buffer, newBuffer, result);
return newBuffer;
}
else
{
return buffer;
}
}

Peter Flaig <fliege>

 

Attached Files
file #2851:  BinaryReaderTest.zip added by fliege (45KiB - application/x-zip-compressed)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 31 Aug 2005 09:24:41 AM UTCdrobossonStatusNone=>Fixed
  Open/ClosedOpen=>Closed
Tue 30 Aug 2005 12:02:08 PM UTCfliegeAttached File-=>Added BinaryReaderTest.zip, #2882

Back to the top


Powered by Savane 3.1-cleanup1