Exemplo n.º 1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            int read = Stream.Read(buffer, offset, count);

            currentEntryTotalReadBytes += read;
            listener.FireCompressedBytesRead(currentEntryTotalReadBytes, currentEntryTotalReadBytes);
            return(read);
        }
Exemplo n.º 2
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            int totalRead = 0;

            while (count > 0)
            {
                int readSize = count;
                if (count > maxPosition - currentPosition)
                {
                    readSize = (int)(maxPosition - currentPosition);
                }

                int read = currentStream.Read(buffer, offset, readSize);
                if (read < 0)
                {
                    throw new EndOfStreamException();
                }

                currentPosition += read;
                offset          += read;
                count           -= read;
                totalRead       += read;
                if (((maxPosition - currentPosition) == 0) &&
                    filePartEnumerator.Current.FileHeader.FileFlags.HasFlag(FileFlags.SPLIT_AFTER))
                {
                    string fileName = filePartEnumerator.Current.FileHeader.FileName;
                    if (!filePartEnumerator.MoveNext())
                    {
                        throw new InvalidFormatException(
                                  "Multi-part rar file is incomplete.  Entry expects a new volume: " + fileName);
                    }
                    InitializeNextFilePart();
                }
                else
                {
                    break;
                }
            }
            currentPartTotalReadBytes  += totalRead;
            currentEntryTotalReadBytes += totalRead;
            streamListener.FireCompressedBytesRead(currentPartTotalReadBytes, currentEntryTotalReadBytes);
            return(totalRead);
        }