Source/Deployer/FileSystem/Gpt/DeviceStream.cs
/// <summary>
/// Some devices cannot read portions that are not modulo a sector, this aims to fix that issue.
/// </summary>
/// <param name="buffer">An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and 
/// (offset + count - 1) replaced by the bytes read from the current source. </param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream. </param>
/// <param name="count">The maximum number of bytes to be read from the current stream.</param>
/// <returns></returns>
Some devices cannot read portions that are not modulo a sector, this aims to fix that issue.
Some devices cannot read portions that are not modulo a sector this aims to fix that issue .
public override int Read(byte[] buffer, int offset, int count)
        {
            if (count % sectorsize != 0)
            {
                long extrastart = Position % sectorsize;
                if (extrastart != 0)
                {
                    Seek(-extrastart, SeekOrigin.Current);
                }
                var addedcount = sectorsize - count % sectorsize;
                var ncount = count + addedcount;
                byte[] tmpbuffer = new byte[extrastart + buffer.Length + addedcount];
                buffer.CopyTo(tmpbuffer, extrastart);
                InternalRead(tmpbuffer, offset, (int)ncount);
                tmpbuffer.ToList().Skip((int)extrastart).Take(count + offset).ToArray().CopyTo(buffer, 0);
                return count;
            }
            return InternalRead(buffer, offset, count);
        }
public override int Read ( byte [ ] buffer , int offset , int count ) { if ( count % sectorsize != 0 ) { long extrastart = Position % sectorsize ; if ( extrastart != 0 ) { Seek ( - extrastart , SeekOrigin . Current ) ; } var addedcount = sectorsize - count % sectorsize ; var ncount = count + addedcount ; byte [ ] tmpbuffer = new byte [ extrastart + buffer . Length + addedcount ] ; buffer . CopyTo ( tmpbuffer , extrastart ) ; InternalRead ( tmpbuffer , offset , ( int ) ncount ) ; tmpbuffer . ToList ( ) . Skip ( ( int ) extrastart ) . Take ( count + offset ) . ToArray ( ) . CopyTo ( buffer , 0 ) ; return count ; } return InternalRead ( buffer , offset , count ) ; }
Some devices cannot read portions that are not modulo a sector, this aims to fix that issue.
Some devices cannot read portions that are not modulo a sector this aims to fix that issue .
None
buffer
byte[]
An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and
(offset + count - 1) replaced by the bytes read from the current source.
An array of bytes . When this method returns the buffer contains the specified byte array with the values between offset and ( offset + count - 1 ) replaced by the bytes read from the current source .
offset
int
The zero-based byte offset in buffer at which to begin storing the data read from the current stream.
The zero - based byte offset in buffer at which to begin storing the data read from the current stream .
count
int
The maximum number of bytes to be read from the current stream.
The maximum number of bytes to be read from the current stream .