diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index 066db5e8..5ee28135 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -61,11 +61,22 @@ namespace GameRes.Utility return AsciiEqual (name1, 0, name2); } + /// + /// Check if sequence of ASCII characters in array is equal to string . + /// This methods avoids costly construction of the string object from byte array for a mere purpose of + /// comparison. + /// public static bool AsciiEqual (byte[] name1, int offset, string name2) { return name1.AsciiEqual (offset, name2); } + /// + /// Copy potentially overlapping sequence of bytes in array + /// from to . + /// If destination offset resides within source region then sequence will repeat itself. Widely used + /// in various compression techniques. + /// public static void CopyOverlapped (byte[] data, int src, int dst, int count) { if (dst > src) @@ -84,6 +95,11 @@ namespace GameRes.Utility } } + /// + /// Extract null-terminated string (a "C string") from array starting + /// at offset up to bytes long, stored in + /// encoding . + /// public static string GetCString (byte[] data, int index, int length_limit, Encoding enc) { int name_length = 0;