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

Submitter:  Peter Flaig <fliege>
Submitted:  Tue 30 Aug 2005 12:00:58 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-08-31 drobosson StatusNone Fixed
    Open/ClosedOpen Closed
2005-08-30 fliege Attached File- Added BinaryReaderTest.zip, #2882

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code