NetWrok.HTTP.Zlib.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 ZlibException ("The input stream must not be null.");

            unchecked {
                //UInt32 crc32Result;
                //crc32Result = 0xFFFFFFFF;
                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) {
                    //for (int i = 0; i < count; i++)
                    //{
                    //    _RunningCrc32Result = ((_RunningCrc32Result) >> 8) ^ crc32Table[(buffer[i]) ^ ((_RunningCrc32Result) & 0x000000FF)];
                    //}

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

                return (Int32)(~_RunningCrc32Result);
            }
        }