High-performance differential patch library powered by Zstd
License: MIT Release GitHub Actions
ZPatch is a high-performance differential patch library powered by Zstd compression. It uses the old file as a dictionary to compress the new file, achieving significantly higher compression ratios than traditional diff algorithms.
- π High Compression Ratio - Leverages Zstd dictionary compression
- π¦ Zero External Dependencies - Pure C++ implementation with bundled Zstd
- π Cross-Platform - Supports Android, iOS, Linux, macOS, Windows
- π± Android Ready - 16KB page size support for Android 15+
- π§ Simple API - Easy to integrate into any project
Pre-built binaries are available on the Releases page:
| File | Platform | Architecture |
|---|---|---|
zpatch-darwin-amd64 |
macOS | x86_64 |
zpatch-darwin-arm64 |
macOS | ARM64 (Apple Silicon) |
zpatch-linux-amd64 |
Linux | x86_64 |
zpatch-android.aar |
Android | AAR Library |
# Show version ./zpatch version # Create a patch ./zpatch create <old-file> <new-file> <patch-file> # Apply a patch ./zpatch apply <old-file> <patch-file> <new-file>
Add to your build.gradle.kts:
dependencies {
implementation("com.github.quickits:zpatch:VERSION")
}Kotlin API:
import com.quickits.zpatch.ZPatch // Create patch val result = ZPatch.createPatch(oldPath, newPath, patchPath) if (result.isSuccess) { println("Patch created: ${result.originalSize} bytes") } // Apply patch val result = ZPatch.applyPatch(oldPath, patchPath, newPath) if (result.isSuccess) { println("File restored: ${result.originalSize} bytes") }
#include "zpatch/core.h" // Create patch zpatch::Result result = zpatch::createPatch("old.bin", "new.bin", "patch.zst"); // Apply patch zpatch::Result result = zpatch::applyPatch("old.bin", "patch.zst", "new.bin");
cd cli # Build for current platform ./build-mac-amd64.sh # macOS x86_64 ./build-mac-arm64.sh # macOS ARM64 ./build-linux-amd64.sh # Linux x86_64 # Build all platforms ./build-all.sh
cd android
./gradlew :library:assembleReleasecd core mkdir build && cd build cmake .. make
namespace zpatch { // Get version information const char* getVersion(); // Create a patch file Result createPatch(const char* oldFile, const char* newFile, const char* patchFile); // Apply a patch file Result applyPatch(const char* oldFile, const char* patchFile, const char* newFile); } struct Result { int code; // 0 = success, non-zero = failure const char* message; // Error message (static string) uint64_t originalSize; // Output file size };
zpatch/
βββ core/ # C++ core library
βββ cli/ # Command-line tool
βββ android/ # Android library + sample app
βββ .github/ # GitHub Actions workflows
MIT License - see LICENSE for details.