RdcFileReader Issue

Issue #1 resolved
long created an issue

Hello

The read function under the RdcFileReader has issue, please use eof = read < bytesToRead; instead of eof = read < bytesRead;

Following is the original code:

public class RdcFileReader : IRdcFileReader { private Stream _stream;

    public RdcFileReader() { }
    public RdcFileReader(Stream stream)
    {
        _stream = stream;
    }

    public void GetFileSize(out ulong fileSize)
    {
        fileSize = (ulong)_stream.Length;
    }

    [PreserveSig]
    public void Read(ulong offsetFileStart, uint bytesToRead, ref uint bytesRead, IntPtr buffer, ref bool eof)
    {            
        if (_stream.Position != (long)offsetFileStart)
        {
            _stream.Seek((long)offsetFileStart, SeekOrigin.Begin);
        }

        var intBuff = new Byte[bytesToRead];
        var read = 0;
        var lastRead = 0;
        do
        {
            lastRead = _stream.Read(intBuff, read, ((int) bytesToRead - read));
            read += lastRead;
        } while (lastRead != 0 && read < bytesToRead);
        bytesRead = (uint) read;
        Marshal.Copy(intBuff, 0, buffer, (int)bytesRead);
        eof = read < bytesToRead;
    }

Comments (1)

  1. Log in to comment