Alexandria.Platforms.Wii.DiscPartitionStream.Read C# (CSharp) Method

Read() public method

Read data from the partition.
public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
return int
        public override int Read(byte[] buffer, int offset, int count)
        {
            int read = 0;

            while (count > 0) {
                int positionCluster = checked((int)(PositionField / NintendoOpticalDiscPartition.ClusterDataSize));

                if (ClusterIndex != positionCluster) {
                    ClusterData = Partition.ReadCluster(positionCluster);
                    ClusterIndex = positionCluster;
                }

                int clusterOffset = checked((int)(PositionField - ClusterIndex * (long)NintendoOpticalDiscPartition.ClusterDataSize)); // Offset within the cluster.
                int toRead = Math.Min(ClusterData.Length - clusterOffset, count);

                ClusterData.CopyTo(clusterOffset, toRead, buffer, offset);
                offset += toRead;
                read += toRead;
                PositionField += toRead;
                count -= toRead;
            }

            return read;
        }