Sfm2Xml.ByteReader.BytesMatch C# (CSharp) Method

BytesMatch() private method

Tests if the data bytes starting at the given position match the given search data.
private BytesMatch ( byte readData, long readPos, byte searchData ) : bool
readData byte Data bytes to examine
readPos long Index into readData to begin examination at
searchData byte Bytes to compare with
return bool
		private bool BytesMatch(byte[] readData, long readPos, byte[] searchData)
		{
			// First test that there are enough bytes before the end of readData to possibly contain
			// searchData:
			if (readPos + searchData.Length > readData.Length)
				return false; // Not enough space to contain searchData

			// Iterate over searchData's bytes, checking that each one matches the corrresponding
			// byte in readData:
			for (long i = 0; i < searchData.LongLength; i++)
				if (readData[readPos + i] != searchData[i])
					return false;

			// All bytes in searchData match:
			return true;
		}