Partial OAB cleanup

This commit is contained in:
Matt Nadareski
2022-05-23 21:16:42 -07:00
parent d37eac02d5
commit 283fa425d4
2 changed files with 21 additions and 26 deletions

View File

@@ -39,20 +39,16 @@ namespace LibMSPackSharp.OAB
/// The input file will be read and the compressed contents written to the
/// output file.
/// </summary>
/// <param name="self">
/// a self-referential pointer to the msoab_decompressor
/// instance being called
/// </param>
/// <param name="input">
/// the filename of the input file. This is passed
/// The filename of the input file. This is passed
/// directly to mspack_system::open().
/// </param>
/// <param name="output">
/// the filename of the output file. This is passed
/// The filename of the output file. This is passed
/// directly to mspack_system::open().
/// </param>
/// <returns>an error code, or MSPACK_ERR_OK if successful</returns>
public Func<Compressor, string, string, Error> Compress;
/// <returns>An error code, or MSPACK_ERR_OK if successful</returns>
public Error Compress(string input, string output) => throw new NotImplementedException();
/// <summary>
/// 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.
/// </summary>
/// <param name="self">
/// a self-referential pointer to the msoab_decompressor
/// instance being called
/// </param>
/// <param name="input">
/// 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().
/// </param>
/// <param name="base">
/// the filename of the original base file containing
/// <param name="baseFile">
/// 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().
/// </param>
/// <param name="output">
/// the filename of the output file. This is passed
/// The filename of the output file. This is passed
/// directly to mspack_system::open().
/// </param>
/// <returns>an error code, or MSPACK_ERR_OK if successful</returns>
public Func<Compressor, string, string, string, Error> CompressIncremental;
/// <returns>An error code, or MSPACK_ERR_OK if successful</returns>
public Error CompressIncremental(string input, string baseFile, string output) => throw new NotImplementedException();
}
}

View File

@@ -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)
/// <summary>
/// Copy between the input and output, if possible
/// </summary>
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;