コード例 #1
0
        public int Read(byte[] buffer, int offset, int count)
        {
            int read = 0;

            if (BasicStream != null) // not yet created
            {
                if (SyncPosition != null)
                {
                    SyncPosition(_BasicStream);
                }
                if (BasicStream.Position < UnreadableHead)
                {
                    BasicStream.Position = UnreadableHead;
                }
                if (CurrentPosition + count < AvaliableLength)
                {
                    read = BasicStream.Read(buffer, offset, count);
                }
                else if (CurrentPosition < AvaliableLength)
                {
                    read = BasicStream.Read(buffer, offset, (int)(AvaliableLength - CurrentPosition));
                }
            }
            if (read < count)
            {
                // zero the end of the buffer
                Array.Clear(buffer, offset + read, count - read);
                read = count;
            }
            return(read);
        }