Patcher.IO.StreamComparer.Compare C# (CSharp) Method

Compare() public static method

public static Compare ( Stream one, Stream other ) : bool
one Stream
other Stream
return bool
        public static bool Compare(Stream one, Stream other)
        {
            BufferedStream oneBuffered = new BufferedStream(one, BufferSize);
            BufferedStream otherBuffered = new BufferedStream(other, BufferSize);

            // Compare length first, if seekable
            if (oneBuffered.CanSeek && otherBuffered.CanSeek)
            {
                if (oneBuffered.Length != otherBuffered.Length)
                    return false;
            }

            while (true)
            {
                int oneByte = oneBuffered.ReadByte();
                int otherByte = otherBuffered.ReadByte();

                // Both streams ended at the same time
                if (oneByte == -1 && otherByte == -1)
                    return true;

                // Read bytes are not equal
                // ore one stream ended before the other
                if (oneByte != otherByte)
                    return false;
            }
        }
StreamComparer