public void WriteEntryTo(Stream writableStream)
        {
            if (this.wroteCurrentEntry)
            {
                throw new ArgumentException("WriteEntryTo or OpenEntryStream can only be called once.");
            }
            if (!((writableStream != null) && writableStream.CanWrite))
            {
                throw new ArgumentNullException("A writable Stream was required.  Use Cancel if that was intended.");
            }
            IReaderExtractionListener listener = this;

            listener.FireEntryExtractionBegin(this.Entry);
            this.Write(writableStream);
            listener.FireEntryExtractionEnd(this.Entry);
            this.wroteCurrentEntry = true;
        }
Example #2
0
        public static long TransferTo(this Stream source, Stream destination, Common.Entry entry, IReaderExtractionListener readerExtractionListener)
        {
            byte[] array = GetTransferByteArray();
            try
            {
                int  count;
                var  iterations = 0;
                long total      = 0;
                while (ReadTransferBlock(source, array, out count))
                {
                    total += count;
                    destination.Write(array, 0, count);
                    iterations++;
                    readerExtractionListener.FireEntryExtractionProgress(entry, total, iterations);
                }
                return(total);
            }
            finally
            {
#if NETCORE
                ArrayPool <byte> .Shared.Return(array);
#endif
            }
        }