An universal patch generator and applier such as using BsDiff/BsPatch and Google Archive Patch.
See details in CHANGELOG.
I have provided a sample. It is based on unit test.
See sample here on Github.
To run the test cases, simply clone this repository, use android studio to compile and run
gradle
dependencies {
//for generator
compile "io.github.lizhangqu:corepatch-core-generator:1.0.4"
//for applier
compile "io.github.lizhangqu:corepatch-core-applier:1.0.4"
}
maven
//for generator
<dependencies>
<dependency>
<groupId>io.github.lizhangqu</groupId>
<artifactId>corepatch-core-generator</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
//for applier
<dependencies>
<dependency>
<groupId>io.github.lizhangqu</groupId>
<artifactId>corepatch-core-applier</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
//get generator
Generator generator = CoreGenerator.getInstance().getGenerator(CoreGeneratorType.BS);
//Generator generator = CoreGenerator.getInstance().getGenerator(CoreGeneratorType.ARCHIVE);
//Generator generator = CoreGenerator.getInstance().getGenerator(CoreGeneratorType.TOTAL);
//Generator generator = CoreGenerator.getInstance().getGenerator("BS");
//Generator generator = CoreGenerator.getInstance().getGenerator("ARCHIVE");
//Generator generator = CoreGenerator.getInstance().getGenerator("TOTAL");
//generate
generator.generate(oldFile, newFile, toGeneratedPatchFile);
//generator.generate(oldFile, newFile, toGeneratedPatchOutputStream);
//md5
String md5 = generator.calculateMD5(toGeneratedPatchFile);
//get applier
Applier applier = CoreApplier.getInstance().getApplier(CoreApplierType.BS);
//Applier applier = CoreApplier.getInstance().getApplier(CoreApplierType.ARCHIVE);
//Applier applier = CoreApplier.getInstance().getApplier(CoreApplierType.TOTAL);
//Applier applier = CoreApplier.getInstance().getApplier("BS");
//Applier applier = CoreApplier.getInstance().getApplier("ARCHIVE");
//Applier applier = CoreApplier.getInstance().getApplier("TOTAL");
//apply
applier.apply(oldFile, pacthFile, toGeneratedNewFile);
//applier.apply(oldFile, pacthInputStream, toGeneratedNewOutputStream);
//md5
String md5 = applier.calculateMD5(toGeneratedNewFile);
CorePatch is under the BSD license. See the LICENSE file for details.