### Xdelta3 Patching (Standard and with -B) Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Provides command-line examples for creating and applying diffs using xdelta3, including variations with the -B flag to specify the old file size. This is useful for scenarios where precise size information is beneficial. ```bash xdelta3 -S lzma -e -9 -n -f -s {old} {new} {pat} xdelta3 -d -f -s {old} {pat} {new} xdelta3 -S lzma -B {oldSize} -e -9 -n -f -s {old} {new} {pat} xdelta3 -B {oldSize} -d -f -s {old} {pat} {new} ``` -------------------------------- ### Hsynz Synchronization Info Generation and Patching Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Illustrates the process of creating synchronization information using hsync_make and then applying it with hsync_demo for efficient file synchronization. Supports various compression levels and types. ```bash hsync_make -s-2k {new} {out_newi} {out_newz} client sync diff&patch by `hsync_demo {old} {newi} {newz} {out_new} -p-1` hsynz p1 zlib: hsync_make -p-1 -c-zlib-9 hsynz p8 zlib: hsync_make -p-8 -c-zlib-9 (run hsync_demo with -p-8) hsynz p1 zstd: hsync_make -p-1 -c-zstd-21-24 hsynz p8 zstd: hsync_make -p-8 -c-zstd-21-24 (run hsync_demo with -p-8) ``` -------------------------------- ### Bsdiff Patching Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Illustrates the basic command-line usage for bsdiff and bspatch to create and apply binary diffs. This is a common and straightforward method for generating patches. ```bash bsdiff {old} {new} {pat} bspatch {old} {new} {pat} ``` -------------------------------- ### Zstd Patching with HDiffPatch Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Demonstrates how to create and apply patches using zstd compression with the --patch-from option. This method is suitable for generating efficient patches for large files. ```bash zstd --ultra -21 --long=24 -f --patch-from={old} {new} -o {pat} zstd -d -f --memory=2047MB --patch-from={old} {pat} -o {new} ``` -------------------------------- ### hpatchz: Apply Binary Diff Files (Command Line) Source: https://context7.com/sisong/hdiffpatch/llms.txt The `hpatchz` command-line tool applies delta patches to reconstruct new files from old files and diff data. It automatically detects patch formats and supports streaming for memory efficiency. Options include checksum validation, forcing overwrites, and creating self-extracting archives. ```bash # Basic patch application hpatchz oldFile.bin patch.diff newFile.bin # Stream mode with custom cache size (for large files) hpatchz -s-64m oldFile.bin patch.diff newFile.bin # Memory mode (load old file entirely into memory) hpatchz -m oldFile.bin patch.diff newFile.bin # Directory patch with checksum validation hpatchz -C-all oldDir/ dirPatch.diff newDir/ # Force overwrite existing output hpatchz -f oldFile.bin patch.diff newFile.bin # Multi-threaded patching (for single compressed diffs) hpatchz -p-4 oldFile.bin patch.diff newFile.bin # Get patch file info hpatchz -info patch.diff # Create self-extracting archive hpatchz patch.diff -X#selfextract.exe ``` -------------------------------- ### Integrating Hpatchz with Xdelta3 and Bsdiff Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Shows how to use hpatchz to apply patches generated by xdelta3 and bsdiff. This allows leveraging the strengths of different patching tools. ```bash hpatchz -m -f {old} {xdelta3-pat} {new} hpatchz -m -f {old} {xdelta3-B-pat} {new} hpatchz -m -f {old} {bsdiff-pat} {new} ``` -------------------------------- ### Hpatchz Patch Application Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Demonstrates the command-line usage for applying patches created by hdiffz or other compatible tools using hpatchz. The -s flag indicates sparse patching. ```bash hpatchz -s-3m -f {old} {pat} {new} ``` -------------------------------- ### Hdiffz Patching with Various Encoders Source: https://github.com/sisong/hdiffpatch/blob/master/README.md Shows how to generate diffs using hdiffz with different compression algorithms like BSD, zlib, lzma2, and zstd. It includes options for standard and 'sparse' diffs, demonstrating flexibility in patch creation. ```bash hdiffz -m-6 -BSD -d -f -p-1 {old} {new} {pat} hdiffz -m-6 -SD -d -f -p-1 -c-zlib-9 {old} {new} {pat} hdiffz -m-6 -SD -d -f -p-1 -c-lzma2-9-16m {old} {new} {pat} hdiffz -m-6 -SD -d -f -p-1 -c-zstd-21-24 {old} {new} {pat} hdiffz -s-64 -SD -d -f -p-1 -c-zlib-9 {old} {new} {pat} hdiffz -s-64 -SD -d -f -p-1 -c-lzma2-9-16m {old} {new} {pat} hdiffz -s-64 -SD -d -f -p-1 -c-zstd-21-24 {old} {new} {pat} ``` -------------------------------- ### hdiffz: Create Binary Diff Files (Command Line) Source: https://context7.com/sisong/hdiffpatch/llms.txt The `hdiffz` command-line tool generates delta (diff) files between two versions of a file or directory. It supports various compression algorithms (zlib, lzma, zstd, bzip2), memory modes, and compatibility with bsdiff4 and VCDIFF formats. Options include streaming for large files and checksum verification. ```bash # Basic file diff with default settings (memory mode, no compression) hdiffz oldFile.bin newFile.bin output.diff # Create compressed diff using zstd with high compression hdiffz -m-6 -SD -c-zstd-21-24 oldFile.bin newFile.bin output.diff # Stream mode for large files (lower memory usage) hdiffz -s-64 -SD -c-lzma2-9-16m largeOld.bin largeNew.bin output.diff # Directory diff with checksum verification hdiffz -c-zstd-21 -C-xxh128 oldDir/ newDir/ dirPatch.diff # Create bsdiff4-compatible patch hdiffz -BSD oldFile.bin newFile.bin bsdiff.patch # Create VCDIFF-compatible patch (xdelta3/open-vcdiff format) hdiffz -VCD-7 oldFile.bin newFile.bin vcdiff.patch # Multi-threaded diff (8 threads) hdiffz -m-6 -SD -c-zstd-21-24 -p-8 oldFile.bin newFile.bin output.diff # Get diff file info hdiffz -info output.diff ``` -------------------------------- ### Rsync-Style Delta Sync with C++ Source: https://context7.com/sisong/hdiffpatch/llms.txt Implements rsync-style patching by downloading only changed blocks for efficient file updates. Includes functions for direct sync patching and a two-step offline process (diff then patch). ```cpp #include "libhsync/sync_client/sync_client.h" // Sync patch: download only changed blocks TSyncClient_resultType syncPatch(const char* oldFile, const char* newSyncInfoFile, const char* outputFile) { return sync_patch_file2file( nullptr, // listener nullptr, // syncDataListener (provides download interface) oldFile, newSyncInfoFile, hpatch_FALSE, // isIgnoreCompressInfo outputFile, hpatch_FALSE, // isOutNewContinue (resume support) nullptr, // cacheDiffInfoFile 4 // threadNum ); } // Two-step sync: diff then patch (for offline scenarios) TSyncClient_resultType syncLocalDiff(const char* oldFile, const char* newSyncInfoFile, const char* diffOutputFile) { return sync_local_diff_file2file( nullptr, nullptr, // syncDataListener oldFile, newSyncInfoFile, hpatch_FALSE, diffOutputFile, kSyncDiff_default, // diffType hpatch_FALSE, // isOutDiffContinue 4 ); } TSyncClient_resultType syncLocalPatch(const char* diffFile, const char* oldFile, const char* newSyncInfoFile, const char* outputFile) { return sync_local_patch_file2file( nullptr, diffFile, oldFile, newSyncInfoFile, hpatch_FALSE, outputFile, hpatch_FALSE, // isOutNewContinue 4 ); } ``` -------------------------------- ### Create Directory Diff - C++ Source: https://context7.com/sisong/hdiffpatch/llms.txt Generates a diff between two directories, identifying added, deleted, and modified files. It supports manifest loading, checksum verification, and configurable diff settings for memory usage and performance. ```cpp #include "dirDiffPatch/dir_diff/dir_diff.h" // Directory diff with manifest support class MyDirDiffListener : public IDirDiffListener { public: bool isExecuteFile(const std::string& fileName) override { // Mark executable files (important for permission preservation) return fileName.find(".exe") != std::string::npos || fileName.find(".sh") != std::string::npos; } void diffRefInfo(size_t oldPathCount, size_t newPathCount, size_t sameFilePairCount, hpatch_StreamPos_t sameFileSize, size_t refOldFileCount, size_t refNewFileCount, hpatch_StreamPos_t refOldFileSize, hpatch_StreamPos_t refNewFileSize) override { printf("Dir diff: %zu old files, %zu new files, %zu same pairs\n", oldPathCount, newPathCount, sameFilePairCount); } }; void createDirDiff(const char* oldDir, const char* newDir, const char* outDiffPath, const hdiff_TCompress* compressor, hpatch_TChecksum* checksum) { TManifest oldManifest, newManifest; // ... load manifests from directories ... THDiffSets settings = { .isDiffInMem = true, .isSingleCompressedDiff = true, .isUseBigCacheMatch = false, .matchScore = 6, .patchStepMemSize = 256*1024, .matchBlockSize = 64, .threadNum = 4 }; MyDirDiffListener listener; hpatch_TFileStreamOutput outStream; hpatch_TFileStreamOutput_open(&outStream, outDiffPath, ~(hpatch_StreamPos_t)0); dir_diff(&listener, oldManifest, newManifest, &outStream.base, compressor, checksum, settings, 48); // maxOpenFileNumber hpatch_TFileStreamOutput_close(&outStream); } ``` -------------------------------- ### C++: Create Compressed Diff Stream Source: https://context7.com/sisong/hdiffpatch/llms.txt This C++ code snippet demonstrates how to create a compressed diff stream between two files using the `create_single_compressed_diff` function from the HDiffPatch library. It loads file data into memory, calls the diff creation function with configurable parameters, and writes the resulting diff data to an output file. This method is recommended for optimal patch files supporting streaming and multi-threaded patching. ```cpp #include "libHDiffPatch/HDiff/diff.h" #include #include // Example: Create compressed diff between two files void createDiff(const char* oldPath, const char* newPath, const char* diffPath) { // Load files into memory std::ifstream oldFile(oldPath, std::ios::binary | std::ios::ate); std::ifstream newFile(newPath, std::ios::binary | std::ios::ate); std::vector oldData(oldFile.tellg()); std::vector newData(newFile.tellg()); oldFile.seekg(0); newFile.seekg(0); oldFile.read((char*)oldData.data(), oldData.size()); newFile.read((char*)newData.data(), newData.size()); // Create diff output std::vector diffData; // Parameters: // - kMinSingleMatchScore: 6 (default, good for binary), 0-4 for pure binary, 4-9 for text // - patchStepMemSize: 256KB default, controls patch memory usage // - isUseBigCacheMatch: false (true uses O(oldSize) memory but faster for dissimilar files) // - threadNum: number of threads for parallel compression create_single_compressed_diff( newData.data(), newData.data() + newData.size(), oldData.data(), oldData.data() + oldData.size(), diffData, nullptr, // compressPlugin: nullptr for uncompressed, or use zlib/lzma/zstd plugin 6, // kMinSingleMatchScore 256*1024, // patchStepMemSize false, // isUseBigCacheMatch nullptr, // listener 4 // threadNum ); // Write diff to file std::ofstream outFile(diffPath, std::ios::binary); outFile.write((char*)diffData.data(), diffData.size()); printf("Diff created: %zu bytes (%.2f%% of new file)\n", diffData.size(), 100.0 * diffData.size() / newData.size()); } ``` -------------------------------- ### Apply Directory Patch with hdiffpatch Source: https://context7.com/sisong/hdiffpatch/llms.txt Applies a directory patch to an old directory to create a new directory. It supports file-level granularity and checksum verification for data integrity. Requires decompressor and checksum plugins. ```cpp #include "dirDiffPatch/dir_patch/dir_patch.h" // Apply directory patch hpatch_BOOL applyDirPatch(const char* oldDir, const char* diffPath, const char* newDir, hpatch_TDecompress* decompressor, hpatch_TChecksum* checksum) { TDirPatcher patcher; TDirPatcher_init(&patcher); // Open diff file hpatch_TFileStreamInput diffStream; hpatch_TFileStreamInput_open(&diffStream, diffPath); const TDirDiffInfo* diffInfo; if (!TDirPatcher_open(&patcher, &diffStream.base, &diffInfo)) { return hpatch_FALSE; } // Setup checksum verification TDirPatchChecksumSet checksumSet = { .checksumPlugin = checksum, .isCheck_oldRefData = hpatch_TRUE, .isCheck_newRefData = hpatch_TRUE, .isCheck_copyFileData = hpatch_TRUE, .isCheck_dirDiffData = hpatch_TRUE }; // Load directory data if (!TDirPatcher_loadDirData(&patcher, decompressor, oldDir, newDir)) { TDirPatcher_close(&patcher); return hpatch_FALSE; } // Open streams const hpatch_TStreamInput* oldRefStream; const hpatch_TStreamOutput* newDirStream; TDirPatcher_openOldRefAsStream(&patcher, 48, &oldRefStream); TDirPatcher_openNewDirAsStream(&patcher, nullptr, &newDirStream); // Apply patch std::vector cache(8*1024*1024); hpatch_BOOL result = TDirPatcher_patch( &patcher, newDirStream, oldRefStream, cache.data(), cache.data() + cache.size(), 4 ); // Cleanup TDirPatcher_closeNewDirStream(&patcher); TDirPatcher_closeOldRefStream(&patcher); TDirPatcher_close(&patcher); hpatch_TFileStreamInput_close(&diffStream); return result; } ``` -------------------------------- ### Create Uncompressed Diff (C++) Source: https://context7.com/sisong/hdiffpatch/llms.txt Generates an uncompressed diff between two data buffers. This is a legacy function and the single compressed diff API is recommended for most applications. It takes pointers and sizes for the old and new data, and outputs the diff data into a vector. A verification function is also provided to check diff correctness. ```cpp #include "libHDiffPatch/HDiff/diff.h" #include // Simple memory-based diff creation void createUncompressedDiff(const unsigned char* oldData, size_t oldSize, const unsigned char* newData, size_t newSize, std::vector& outDiff) { create_diff( newData, newData + newSize, oldData, oldData + oldSize, outDiff, 6, // kMinSingleMatchScore: match quality threshold false, // isUseBigCacheMatch: use big cache for speed 1 // threadNum: single thread ); } // Verify diff correctness bool verifyDiff(const unsigned char* oldData, size_t oldSize, const unsigned char* newData, size_t newSize, const unsigned char* diffData, size_t diffSize) { return check_diff( newData, newData + newSize, oldData, oldData + oldSize, diffData, diffData + diffSize ); } ``` -------------------------------- ### Create Compressed Diff Stream - C++ Source: https://context7.com/sisong/hdiffpatch/llms.txt Creates compressed diffs using a stream-based approach, suitable for memory-constrained environments. It allows configuration of block size for memory/speed/size tradeoffs and supports multi-threading. ```cpp #include "libHDiffPatch/HDiff/diff.h" // Stream diff with configurable block size and compression void createStreamDiff(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* newStream, const hpatch_TStreamOutput* outDiff, const hdiff_TCompress* compressor) { // kMatchBlockSize controls memory/speed/size tradeoff: // - Smaller (16-64): smaller diff, more memory, slower // - Larger (1K-64K): larger diff, less memory, faster size_t kMatchBlockSize = 64; // Multi-thread settings hdiff_TMTSets_s mtSets = { .threadNum = 4, .threadNumForSearch = 4, .newDataIsMTSafe = true, .oldDataIsMTSafe = true }; create_compressed_diff_stream( newStream, oldStream, outDiff, compressor, kMatchBlockSize, &mtSets ); } ``` -------------------------------- ### create_bsdiff - Create bsdiff4-Compatible Diff Source: https://context7.com/sisong/hdiffpatch/llms.txt Creates diff files compatible with the classic bsdiff4 format for interoperability with existing tools. This function takes old and new data buffers, an output stream for the diff file, and an optional bz2 compressor. ```APIDOC ## create_bsdiff - Create bsdiff4-Compatible Diff ### Description Creates diff files compatible with the classic bsdiff4 format for interoperability with existing tools. ### Method (Not specified, likely a C++ function call) ### Endpoint (Not applicable, C++ function) ### Parameters #### Path Parameters (Not applicable) #### Query Parameters (Not applicable) #### Request Body (Not applicable) ### Request Example ```cpp #include "bsdiff_wrapper/bsdiff_wrapper.h" void createBsdiff(const unsigned char* oldData, size_t oldSize, const unsigned char* newData, size_t newSize, const hpatch_TStreamOutput* outDiff, const hdiff_TCompress* bz2Compressor) ``` ### Response #### Success Response (200) (Not specified, returns void) #### Response Example (Not specified) ``` -------------------------------- ### Create VCDIFF-Compatible Diff (RFC 3284) Source: https://context7.com/sisong/hdiffpatch/llms.txt Creates diff files in VCDIFF format, adhering to RFC 3284. This is compatible with tools like xdelta3 and open-vcdiff. It supports stream-based inputs and optional compression. ```cpp #include "vcdiff_wrapper/vcdiff_wrapper.h" // Create VCDIFF-compatible patch (RFC 3284) void createVcdiff(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* newStream, const hpatch_TStreamOutput* outDiff, const vcdiff_TCompress* compressor) { create_vcdiff( newStream, oldStream, outDiff, compressor, // nullptr for uncompressed, or lzma for xdelta3 -S lzma compatibility 6, // kMinSingleMatchScore false, // isUseBigCacheMatch nullptr, // coverLinesListener 4 // threadNum ); } ``` ```cpp // Stream-based VCDIFF for large files void createVcdiffStream(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* newStream, const hpatch_TStreamOutput* outDiff) { hdiff_TMTSets_s mtSets = {4, 4, true, true}; create_vcdiff_stream( newStream, oldStream, outDiff, nullptr, // compressor 64, // kMatchBlockSize &mtSets ); } ``` -------------------------------- ### TDirPatcher - Apply Directory Diff Source: https://context7.com/sisong/hdiffpatch/llms.txt Applies directory patches with file-level granularity and checksum verification. This function takes the old directory, the diff patch file, and the new directory path as input, along with decompressor and checksum plugins for verification. ```APIDOC ## TDirPatcher - Apply Directory Diff ### Description Applies directory patches with file-level granularity and checksum verification. ### Method (Not specified, likely a C++ function call) ### Endpoint (Not applicable, C++ function) ### Parameters #### Path Parameters (Not applicable) #### Query Parameters (Not applicable) #### Request Body (Not applicable) ### Request Example ```cpp #include "dirDiffPatch/dir_patch/dir_patch.h" hpatch_BOOL applyDirPatch(const char* oldDir, const char* diffPath, const char* newDir, hpatch_TDecompress* decompressor, hpatch_TChecksum* checksum) ``` ### Response #### Success Response (200) (Not specified, returns hpatch_BOOL) #### Response Example (Not specified) ``` -------------------------------- ### Apply Uncompressed Diff (Legacy) - C++ Source: https://context7.com/sisong/hdiffpatch/llms.txt Applies uncompressed diffs in memory or via streams. Requires all data to fit in memory for the in-memory version. The stream-based version uses a custom cache for handling large files. ```cpp #include "libHDiffPatch/HPatch/patch.h" // Apply patch in memory bool applyPatchMem(const unsigned char* oldData, size_t oldSize, const unsigned char* diffData, size_t diffSize, unsigned char* newData, size_t newSize) { return patch( newData, newData + newSize, oldData, oldData + oldSize, diffData, diffData + diffSize ) == hpatch_TRUE; } // Stream-based patch with custom cache for large files bool applyPatchStream(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* diffStream, const hpatch_TStreamOutput* newStream, unsigned char* cache, size_t cacheSize) { // cacheSize must be >= 2048 bytes return patch_stream_with_cache( newStream, oldStream, diffStream, cache, cache + cacheSize ) == hpatch_TRUE; } ``` -------------------------------- ### Apply Compressed Diff with patch_single_stream (C++) Source: https://context7.com/sisong/hdiffpatch/llms.txt Applies a single compressed diff to reconstruct new data. This function supports streaming, multi-threaded decompression, and step-by-step patching. It requires file stream inputs for old data, diff data, and an output stream for the new data. A listener callback is used to manage decompression plugins and temporary cache. ```cpp #include "libHDiffPatch/HPatch/patch.h" #include // Listener callback structure for patch operation struct MyPatchListener : sspatch_listener_t { hpatch_TDecompress* decompressPlugin; std::vector cache; static hpatch_BOOL onDiffInfo(sspatch_listener_t* listener, const hpatch_singleCompressedDiffInfo* info, hpatch_TDecompress** out_decompressPlugin, unsigned char** out_temp_cache, unsigned char** out_temp_cacheEnd) { MyPatchListener* self = (MyPatchListener*)listener; // Allocate cache: stepMemSize + I/O cache (at least 3*4KB) size_t cacheSize = info->stepMemSize + 1024*64; self->cache.resize(cacheSize); *out_decompressPlugin = self->decompressPlugin; *out_temp_cache = self->cache.data(); *out_temp_cacheEnd = self->cache.data() + self->cache.size(); return hpatch_TRUE; } }; // Example: Apply patch from diff file hpatch_BOOL applyPatch(const char* oldPath, const char* diffPath, const char* newPath) { // Open old file as stream hpatch_TFileStreamInput oldStream; hpatch_TFileStreamInput diffStream; hpatch_TFileStreamOutput newStream; if (!hpatch_TFileStreamInput_open(&oldStream, oldPath)) return hpatch_FALSE; if (!hpatch_TFileStreamInput_open(&diffStream, diffPath)) return hpatch_FALSE; // Get diff info first hpatch_singleCompressedDiffInfo diffInfo; if (!getSingleCompressedDiffInfo(&diffInfo, &diffStream.base, 0)) { hpatch_TFileStreamInput_close(&oldStream); hpatch_TFileStreamInput_close(&diffStream); return hpatch_FALSE; } // Create output file if (!hpatch_TFileStreamOutput_open(&newStream, newPath, diffInfo.newDataSize)) { hpatch_TFileStreamInput_close(&oldStream); hpatch_TFileStreamInput_close(&diffStream); return hpatch_FALSE; } // Setup listener MyPatchListener listener = {}; listener.onDiffInfo = MyPatchListener::onDiffInfo; listener.decompressPlugin = nullptr; // Set appropriate decompressor based on diffInfo.compressType // Apply patch with multi-threading support hpatch_BOOL result = patch_single_stream( &listener, &newStream.base, &oldStream.base, &diffStream.base, 0, // diffInfo_pos: start position in diff stream nullptr, // coversListener: optional callback for cover info 4 // threadNum: 1-5 threads for I/O and decompression ); hpatch_TFileStreamOutput_close(&newStream); hpatch_TFileStreamInput_close(&oldStream); hpatch_TFileStreamInput_close(&diffStream); return result; } ``` -------------------------------- ### Create bsdiff4-Compatible Diff Source: https://context7.com/sisong/hdiffpatch/llms.txt Generates a diff file in the bsdiff4 format, ensuring compatibility with classic bsdiff tools. This function takes raw data buffers for old and new versions and an output stream, optionally using a bz2 compressor. ```cpp #include "bsdiff_wrapper/bsdiff_wrapper.h" // Create bsdiff4-compatible patch void createBsdiff(const unsigned char* oldData, size_t oldSize, const unsigned char* newData, size_t newSize, const hpatch_TStreamOutput* outDiff, const hdiff_TCompress* bz2Compressor) { create_bsdiff( newData, newData + newSize, oldData, oldData + oldSize, outDiff, bz2Compressor, false, // isEndsleyBsdiff: false for standard bsdiff4, true for endsley/bsdiff format 6, // kMinSingleMatchScore false, // isUseBigCacheMatch nullptr,// coverLinesListener 1 // threadNum ); } ``` -------------------------------- ### create_vcdiff - Create VCDIFF-Compatible Diff (RFC 3284) Source: https://context7.com/sisong/hdiffpatch/llms.txt Creates diff files in VCDIFF format compatible with xdelta3 and open-vcdiff tools. This function supports stream-based input for old and new data and an output stream for the diff file. ```APIDOC ## create_vcdiff - Create VCDIFF-Compatible Diff (RFC 3284) ### Description Creates diff files in VCDIFF format compatible with xdelta3 and open-vcdiff tools. ### Method (Not specified, likely a C++ function call) ### Endpoint (Not applicable, C++ function) ### Parameters #### Path Parameters (Not applicable) #### Query Parameters (Not applicable) #### Request Body (Not applicable) ### Request Example ```cpp #include "vcdiff_wrapper/vcdiff_wrapper.h" void createVcdiff(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* newStream, const hpatch_TStreamOutput* outDiff, const vcdiff_TCompress* compressor) ``` ### Response #### Success Response (200) (Not specified, returns void) #### Response Example (Not specified) ``` -------------------------------- ### create_vcdiff_stream - Stream-based VCDIFF for large files Source: https://context7.com/sisong/hdiffpatch/llms.txt Creates VCDIFF diff files using a stream-based approach, suitable for handling large files efficiently. This function takes stream inputs for old and new data and an output stream for the diff file. ```APIDOC ## create_vcdiff_stream - Stream-based VCDIFF for large files ### Description Stream-based VCDIFF for large files. ### Method (Not specified, likely a C++ function call) ### Endpoint (Not applicable, C++ function) ### Parameters #### Path Parameters (Not applicable) #### Query Parameters (Not applicable) #### Request Body (Not applicable) ### Request Example ```cpp #include "vcdiff_wrapper/vcdiff_wrapper.h" void createVcdiffStream(const hpatch_TStreamInput* oldStream, const hpatch_TStreamInput* newStream, const hpatch_TStreamOutput* outDiff) ``` ### Response #### Success Response (200) (Not specified, returns void) #### Response Example (Not specified) ``` -------------------------------- ### Android JNI Patching with Java Source: https://context7.com/sisong/hdiffpatch/llms.txt Provides a Java Native Interface (JNI) for applying patches on Android devices using the native HDiffPatch library. Supports multiple patch formats and allows customization of cache and thread settings. ```java package com.github.sisong; public class HPatch { static { System.loadLibrary("hpatchz"); } // Apply patch with custom cache and thread settings // Returns 0 on success, non-zero error code on failure public static native int patch( String oldFileName, String diffFileName, String outNewFileName, long cacheMemory, // Recommended: 64KB-1MB for file I/O buffering int threadNum // 1-5 for multi-threaded patching ); // Convenience method with default settings public static int patch(String oldFile, String diffFile, String newFile) { return patch(oldFile, diffFile, newFile, 256*1024, 1); } } // Usage example public class PatchExample { public void applyUpdate(String oldApk, String patchFile, String newApk) { int result = HPatch.patch(oldApk, patchFile, newApk, 1024*1024, 4); if (result == 0) { Log.i("Patch", "Update applied successfully"); } else { Log.e("Patch", "Patch failed with error code: " + result); } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.