Files
dnf-utils/sgutil/sgu_mode_apply_patch.h
T
jinchao b78ee53326 累计更新:
cos上传
补丁压缩
2025-12-06 16:29:26 +08:00

23 lines
1.2 KiB
C

#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.
* @param compressMethod 0:Not compress 1: bzip 2:zstd
* @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, int32_t compressMethod);