From 283fa425d432169a69a2d7c2f8f7ffb980138d0a Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 23 May 2022 21:16:42 -0700 Subject: [PATCH] Partial OAB cleanup --- .../External/libmspack/OAB/Compressor.cs | 28 +++++++------------ .../External/libmspack/OAB/Decompressor.cs | 19 +++++++------ 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/BurnOutSharp/External/libmspack/OAB/Compressor.cs b/BurnOutSharp/External/libmspack/OAB/Compressor.cs index 3d7a80a4..c1c7abcb 100644 --- a/BurnOutSharp/External/libmspack/OAB/Compressor.cs +++ b/BurnOutSharp/External/libmspack/OAB/Compressor.cs @@ -39,20 +39,16 @@ namespace LibMSPackSharp.OAB /// The input file will be read and the compressed contents written to the /// output file. /// - /// - /// a self-referential pointer to the msoab_decompressor - /// instance being called - /// /// - /// the filename of the input file. This is passed + /// The filename of the input file. This is passed /// directly to mspack_system::open(). /// /// - /// the filename of the output file. This is passed + /// The filename of the output file. This is passed /// directly to mspack_system::open(). /// - /// an error code, or MSPACK_ERR_OK if successful - public Func Compress; + /// An error code, or MSPACK_ERR_OK if successful + public Error Compress(string input, string output) => throw new NotImplementedException(); /// /// Generate a compressed incremental OAB patch file. @@ -61,26 +57,22 @@ namespace LibMSPackSharp.OAB /// incremental patch to generate "input" from "base" will be written to /// the output file. /// - /// - /// a self-referential pointer to the msoab_decompressor - /// instance being called - /// /// - /// the filename of the input file containing the new + /// The filename of the input file containing the new /// version of its contents. This is passed directly /// to mspack_system::open(). /// - /// - /// the filename of the original base file containing + /// + /// The filename of the original base file containing /// the old version of its contents, against which the /// incremental patch shall generated. This is passed /// directly to mspack_system::open(). /// /// - /// the filename of the output file. This is passed + /// The filename of the output file. This is passed /// directly to mspack_system::open(). /// - /// an error code, or MSPACK_ERR_OK if successful - public Func CompressIncremental; + /// An error code, or MSPACK_ERR_OK if successful + public Error CompressIncremental(string input, string baseFile, string output) => throw new NotImplementedException(); } } diff --git a/BurnOutSharp/External/libmspack/OAB/Decompressor.cs b/BurnOutSharp/External/libmspack/OAB/Decompressor.cs index cde2dd4d..94db15b5 100644 --- a/BurnOutSharp/External/libmspack/OAB/Decompressor.cs +++ b/BurnOutSharp/External/libmspack/OAB/Decompressor.cs @@ -474,21 +474,24 @@ namespace LibMSPackSharp.OAB #region Helpers - private Error CopyFileHandle(FileStream infh, FileStream outfh, int bytes_to_copy, byte[] buf, int buf_size) + /// + /// Copy between the input and output, if possible + /// + private Error CopyFileHandle(FileStream input, FileStream output, int bytesToCopy, byte[] buf, int bufferSize) { - while (bytes_to_copy != 0) + while (bytesToCopy != 0) { - int run = buf_size; - if (run > bytes_to_copy) - run = bytes_to_copy; + int run = bufferSize; + if (run > bytesToCopy) + run = bytesToCopy; - if (System.Read(infh, buf, 0, run) != run) + if (System.Read(input, buf, 0, run) != run) return Error.MSPACK_ERR_READ; - if (outfh != null && System.Write(outfh, buf, 0, run) != run) + if (output != null && System.Write(output, buf, 0, run) != run) return Error.MSPACK_ERR_WRITE; - bytes_to_copy -= run; + bytesToCopy -= run; } return Error.MSPACK_ERR_OK;