diff --git a/LibBundle/BundleContainer.cs b/LibBundle/BundleContainer.cs index 75c1e86..535fb60 100644 --- a/LibBundle/BundleContainer.cs +++ b/LibBundle/BundleContainer.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.InteropServices; @@ -7,10 +6,8 @@ namespace LibBundle { public class BundleContainer { [DllImport("oo2core_8_win64.dll")] - [SuppressMessage("Interoperability", "CA1401:不應看得見 P/Invoke")] public static extern int OodleLZ_Decompress(byte[] buffer, int bufferSize, byte[] result, long outputBufferSize, int a, int b, int c, IntPtr d, long e, IntPtr f, IntPtr g, IntPtr h, long i, int ThreadModule); [DllImport("oo2core_8_win64.dll")] - [SuppressMessage("Interoperability", "CA1401:不應看得見 P/Invoke")] public static extern int OodleLZ_Compress(ENCODE_TYPES format, byte[] buffer, long bufferSize, byte[] outputBuffer, COMPRESSTION_LEVEL level, IntPtr opts, long offs, long unused, IntPtr scratch, long scratch_size); public enum ENCODE_TYPES { LZH = 0, @@ -118,7 +115,7 @@ public virtual MemoryStream Read(BinaryReader br) { var b = br.ReadBytes(chunks[i]); var size = (i + 1 == entry_count) ? uncompressed_size - (chunk_size * (entry_count - 1)) : chunk_size; // isLast ? var toSave = new byte[size + 64]; - OodleLZ_Decompress(b, b.Length, toSave, size, 0, 0, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0, 3); + _ = OodleLZ_Decompress(b, b.Length, toSave, size, 0, 0, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0, 3); data.Write(toSave, 0, size); } diff --git a/LibBundle/IndexContainer.cs b/LibBundle/IndexContainer.cs index 5f60d87..828d28e 100644 --- a/LibBundle/IndexContainer.cs +++ b/LibBundle/IndexContainer.cs @@ -57,7 +57,7 @@ public IndexContainer(BinaryReader br) databr.BaseStream.Seek(tmp, SeekOrigin.Begin); var directoryBundle = new BundleContainer(databr); - var br2 = new BinaryReader(directoryBundle.Read(databr)); + var br2 = new BinaryReader(directoryBundle.Read(databr), Encoding.UTF8); // Array.Sort(Directorys, new Comparison((dr1, dr2) => { return dr1.Offset > dr2.Offset ? 1 : -1; })); foreach (var d in Directorys) { @@ -183,15 +183,15 @@ public BundleRecord GetSmallestBundle(IList Bundles = null) public static ulong FNV1a64Hash(string str) { if (str.EndsWith('/')) - str = str.TrimEnd(new char[] { '/' }) + "++"; + str = str.TrimEnd('/') + "++"; else str = str.ToLower() + "++"; var bs = Encoding.UTF8.GetBytes(str); - var hash = 0xcbf29ce484222325L; + var hash = 0xCBF29CE484222325UL; foreach (var by in bs) - hash = (hash ^ by) * 0x100000001b3; - // Equal to: bs.Aggregate(0xcbf29ce484222325, (current, by) => (current ^ by) * 0x100000001b3); + hash = (hash ^ by) * 0x100000001B3UL; + // Equal to: bs.Aggregate(0xCBF29CE484222325UL, (current, by) => (current ^ by) * 0x100000001B3); return hash; } } diff --git a/LibBundle/LibBundle.csproj b/LibBundle/LibBundle.csproj index 5288c84..b35b042 100644 --- a/LibBundle/LibBundle.csproj +++ b/LibBundle/LibBundle.csproj @@ -4,8 +4,9 @@ net5.0 aianlinb Copyright © 2020 aianlinb. - 2.4.1.0 + 2.4.2.0 x64 + true diff --git a/LibBundle/Records/BundleRecord.cs b/LibBundle/Records/BundleRecord.cs index 27f1d1b..9f2278c 100644 --- a/LibBundle/Records/BundleRecord.cs +++ b/LibBundle/Records/BundleRecord.cs @@ -56,8 +56,10 @@ public void Read(BinaryReader br = null, long? Offset = null) public void Save(string newPath = null, string originalPath = null) { if (newPath == null && originalPath == null && Bundle.path == null) - throw new ArgumentNullException(); - var data = new MemoryStream(); +#pragma warning disable CA2208 // 正確地將引數例外狀況具現化 + throw new ArgumentNullException(); +#pragma warning restore CA2208 // 正確地將引數例外狀況具現化 + var data = new MemoryStream(); foreach (var d in FileToAdd) { d.Key.Offset = (int)data.Position + Bundle.uncompressed_size;