Ionic.Crc.CRC32.GetCrc32AndCopy C# (CSharp) Method

GetCrc32AndCopy() public method

Returns the CRC32 for the specified stream, and writes the input into the output stream.
public GetCrc32AndCopy ( System input, System output ) : Int32
input System The stream over which to calculate the CRC32
output System The stream into which to deflate the input
return System.Int32
        public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output)
        {
            if (input == null)
                throw new Exception("The input stream must not be null.");

            unchecked
            {
                byte[] buffer = new byte[BUFFER_SIZE];
                int readSize = BUFFER_SIZE;

                _TotalBytesRead = 0;
                int count = input.Read(buffer, 0, readSize);
                if (output != null) output.Write(buffer, 0, count);
                _TotalBytesRead += count;
                while (count > 0)
                {
                    SlurpBlock(buffer, 0, count);
                    count = input.Read(buffer, 0, readSize);
                    if (output != null) output.Write(buffer, 0, count);
                    _TotalBytesRead += count;
                }

                return (Int32)(~_register);
            }
        }