From 6c1b8641c2263bd0b4bba561685e47d16a437da4 Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 6 Dec 2017 08:52:17 +0400 Subject: [PATCH] (ArcView.BytesEqual): new method. --- GameRes/ArcView.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/GameRes/ArcView.cs b/GameRes/ArcView.cs index 307fb1a0..7bdbec05 100644 --- a/GameRes/ArcView.cs +++ b/GameRes/ArcView.cs @@ -311,6 +311,22 @@ namespace GameRes 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) { if (Reserve (offset, (uint)data.Length) < (uint)data.Length)