Src/Pscx/Commands/IO/Compression/ArchiveWriter/WriterBase.cs
/// <summary>
/// Copy the contents of one <see cref="Stream"/> to another.
/// </summary>
/// <param name="source">The stream to source data from.</param>
/// <param name="destination">The stream to write data to.</param>
/// <param name="buffer">The buffer to use during copying.</param>
/// <remarks>This is taken from SharpZipLib.Core.StreamUtils and modified for progress callbacks.</remarks>
Copy the contents of one  to another.
Copy the contents of one to another .
protected void Copy(Stream source, Stream destination, byte[] buffer)
        {
            PscxArgumentException.ThrowIfIsNull(source, "source");
            PscxArgumentException.ThrowIfIsNull(destination, "destination");
            PscxArgumentException.ThrowIfIsNull(buffer, "buffer");
            PscxArgumentException.ThrowIf(buffer.Length < 128, "Buffer is too small");
            long sourceLength = source.Length;
            long bytesWritten = 0;
            bool copying = true;
            Debug.WriteLine("StartCopy", "WriterBase.Copy");
            while (copying)
            {
                int bytesRead = source.Read(buffer, 0, buffer.Length);
                if (bytesRead > 0)
                {
                    destination.Write(buffer, 0, bytesRead);
                    bytesWritten += bytesRead;
                    OnWriteProgress(sourceLength, bytesWritten);
                }
                else
                {
                    destination.Flush();
                    copying = false;
                }
            }
            OnWriteComplete();
            Debug.WriteLine("EndCopy", "WriterBase.Copy");
        }
protected void Copy ( Stream source , Stream destination , byte [ ] buffer ) { PscxArgumentException . ThrowIfIsNull ( source , " " ) ; PscxArgumentException . ThrowIfIsNull ( destination , " " ) ; PscxArgumentException . ThrowIfIsNull ( buffer , " " ) ; PscxArgumentException . ThrowIf ( buffer . Length < 128 , " " ) ; long sourceLength = source . Length ; long bytesWritten = 0 ; bool copying = true ; Debug . WriteLine ( " " , " " ) ; while ( copying ) { int bytesRead = source . Read ( buffer , 0 , buffer . Length ) ; if ( bytesRead > 0 ) { destination . Write ( buffer , 0 , bytesRead ) ; bytesWritten += bytesRead ; OnWriteProgress ( sourceLength , bytesWritten ) ; } else { destination . Flush ( ) ; copying = false ; } } OnWriteComplete ( ) ; Debug . WriteLine ( " " , " " ) ; }
Copy the contents of one  to another.
Copy the contents of one to another .
source
Stream
The stream to source data from.
The stream to source data from .
destination
Stream
The stream to write data to.
The stream to write data to .
buffer
byte[]
The buffer to use during copying.
The buffer to use during copying .
remarks
This is taken from SharpZipLib.Core.StreamUtils and modified for progress callbacks.
This is taken from SharpZipLib . Core . StreamUtils and modified for progress callbacks .