(ArcView.BytesEqual): new method.

This commit is contained in:
morkt 2017-12-06 08:52:17 +04:00
parent 716e6d27c8
commit 6c1b8641c2

View File

@ -311,6 +311,22 @@ namespace GameRes
throw new ArgumentException ("Not enough bytes to read in the memory mapped file view.", "offset"); throw new ArgumentException ("Not enough bytes to read in the memory mapped file view.", "offset");
} }
public bool BytesEqual (long offset, byte[] data)
{
if (Reserve (offset, (uint)data.Length) < (uint)data.Length)
return false;
unsafe
{
byte* ptr = m_mem + (offset - m_offset);
for (int i = 0; i < data.Length; ++i)
{
if (ptr[i] != data[i])
return false;
}
return true;
}
}
public bool AsciiEqual (long offset, string data) public bool AsciiEqual (long offset, string data)
{ {
if (Reserve (offset, (uint)data.Length) < (uint)data.Length) if (Reserve (offset, (uint)data.Length) < (uint)data.Length)