initial commit

This commit is contained in:
2025-09-01 20:47:58 +08:00
commit 12c51b5ddb
843 changed files with 475321 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#pragma once
/**
* Applies a BSDIFF43 binary patch to an input file and writes the patched result to an output file.
*
* @param inputFilename The path to the original input file to be patched.
* @param patchFilename The path to the BSDIFF43 patch file (bzip2-compressed).
* @param outputFilename The path to the output file where the patched result will be written.
* @return true if the patch is applied successfully; false otherwise.
*
* The function performs the following steps:
* 1. Validates input, patch, and output file names.
* 2. Reads the input file into memory.
* 3. Opens the patch file and verifies its BSDIFF43 header.
* 4. Reads the expected output file size from the patch header and allocates a buffer for the output.
* 5. Initializes bzip2 decompression for the patch data.
* 6. Uses the bspatch algorithm to apply the patch, writing the result to the output buffer.
* 7. Writes the patched data to the output file.
* 8. Cleans up all resources and returns true on success, or false if any error occurs.
*/
bool applyPatch(const char* inputFilename, const char* patchFilename, const char* outputFilename);