From ce54fb1a4ec93deb376ed5987925dca2afd51858 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 23 Jul 2015 20:23:14 +0400 Subject: [PATCH] NotTransorm class moved to common namespace. --- ArcFormats/ArcCommon.cs | 47 +++++++++++++++++++++++++++++++++++++---- ArcFormats/ArcKogado.cs | 32 ---------------------------- ArcFormats/ArcSPack.cs | 2 +- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/ArcFormats/ArcCommon.cs b/ArcFormats/ArcCommon.cs index 02a9be54..2ca0bbe6 100644 --- a/ArcFormats/ArcCommon.cs +++ b/ArcFormats/ArcCommon.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Cryptography; using System.Text; namespace GameRes.Formats @@ -296,7 +297,14 @@ namespace GameRes.Formats Compress, }; - internal sealed class LzssCoroutine + public class LzssSettings + { + public int FrameSize { get; set; } + public byte FrameFill { get; set; } + public int FrameInitPos { get; set; } + } + + internal sealed class LzssCoroutine : LzssSettings { byte[] m_buffer; int m_offset; @@ -306,9 +314,6 @@ namespace GameRes.Formats IEnumerator m_unpack; - public int FrameSize { get; set; } - public byte FrameFill { get; set; } - public int FrameInitPos { get; set; } public bool Eof { get; private set; } public LzssCoroutine (Stream input) @@ -394,6 +399,8 @@ namespace GameRes.Formats m_should_dispose = !leave_open; } + public LzssSettings Config { get { return m_reader; } } + public override bool CanRead { get { return m_input.CanRead; } } public override bool CanSeek { get { return false; } } public override bool CanWrite { get { return false; } } @@ -626,4 +633,36 @@ namespace GameRes.Formats return (uint)(((-1 << m_cached_bits) & mask) >> m_cached_bits); } } + + public sealed class NotTransform : ICryptoTransform + { + private const int BlockSize = 256; + + public bool CanReuseTransform { get { return true; } } + public bool CanTransformMultipleBlocks { get { return true; } } + public int InputBlockSize { get { return BlockSize; } } + public int OutputBlockSize { get { return BlockSize; } } + + public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, + byte[] outputBuffer, int outputOffset) + { + for (int i = 0; i < inputCount; ++i) + { + outputBuffer[outputOffset++] = (byte)~inputBuffer[inputOffset+i]; + } + return inputCount; + } + + public byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount) + { + byte[] outputBuffer = new byte[inputCount]; + TransformBlock (inputBuffer, inputOffset, inputCount, outputBuffer, 0); + return outputBuffer; + } + + public void Dispose () + { + System.GC.SuppressFinalize (this); + } + } } diff --git a/ArcFormats/ArcKogado.cs b/ArcFormats/ArcKogado.cs index 4f3779f5..511c07b8 100644 --- a/ArcFormats/ArcKogado.cs +++ b/ArcFormats/ArcKogado.cs @@ -398,36 +398,4 @@ namespace GameRes.Formats.Kogado } } } - - public sealed class NotTransform : ICryptoTransform - { - private const int BlockSize = 256; - - public bool CanReuseTransform { get { return true; } } - public bool CanTransformMultipleBlocks { get { return true; } } - public int InputBlockSize { get { return BlockSize; } } - public int OutputBlockSize { get { return BlockSize; } } - - public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, - byte[] outputBuffer, int outputOffset) - { - for (int i = 0; i < inputCount; ++i) - { - outputBuffer[outputOffset++] = (byte)~inputBuffer[inputOffset+i]; - } - return inputCount; - } - - public byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount) - { - byte[] outputBuffer = new byte[inputCount]; - TransformBlock (inputBuffer, inputOffset, inputCount, outputBuffer, 0); - return outputBuffer; - } - - public void Dispose () - { - System.GC.SuppressFinalize (this); - } - } } diff --git a/ArcFormats/ArcSPack.cs b/ArcFormats/ArcSPack.cs index c8a112ab..df4239b2 100644 --- a/ArcFormats/ArcSPack.cs +++ b/ArcFormats/ArcSPack.cs @@ -102,7 +102,7 @@ namespace GameRes.Formats.SPack if (null == packed_entry || !packed_entry.IsPacked) return input; if (1 == packed_entry.Method) - return new CryptoStream (input, new Kogado.NotTransform(), CryptoStreamMode.Read); + return new CryptoStream (input, new NotTransform(), CryptoStreamMode.Read); if (2 == packed_entry.Method) { using (var reader = new PackedReader (packed_entry, input))