From afa8b24ba9095e0c470462a4c2030769921c8a70 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 14 Dec 2022 16:33:26 -0800 Subject: [PATCH] Add MoPaQ printing skeleton --- BurnOutSharp/Tools/Utilities.cs | 3 +++ Test/Program.cs | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index 421992c2..53b3512c 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -278,6 +278,9 @@ namespace BurnOutSharp.Tools if (magic.StartsWith(new byte?[] { 0x4d, 0x50, 0x51, 0x1a })) return SupportedFileType.MPQ; + if (magic.StartsWith(new byte?[] { 0x4d, 0x50, 0x51, 0x1b })) + return SupportedFileType.MPQ; + #endregion #region MSI diff --git a/Test/Program.cs b/Test/Program.cs index efa95b0e..722389be 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -292,6 +292,19 @@ namespace Test } } + // MoPaQ (MPQ) archive + else if (IsMoPaQ(magic)) + { + // Build the archive information + Console.WriteLine("Creating MoPaQ deserializer"); + Console.WriteLine(); + + // TODO: Write and use printing methods + Console.WriteLine("MoPaQ archive printing not currently enabled"); + Console.WriteLine(); + return; + } + // MS-CAB archive else if (IsMSCAB(magic)) { @@ -321,6 +334,17 @@ namespace Test } } + /// + /// Determine if the magic bytes indicate an MoPaQ archive + /// + private static bool IsMoPaQ(byte[] magic) + { + if (magic == null || magic.Length < 4) + return false; + + return magic[0] == 'M' && magic[1] == 'P' && magic[2] == 'Q' && (magic[3] == 0x1A || magic[3] == 0x1B); + } + /// /// Determine if the magic bytes indicate an MS-CAB archive ///