Expand description
§bsdiff-android
Bsdiff/bspatch implementation with Android BSDF2 format support. Compatible with Android OTA payloads.
§Usage
fn main() {
let one = vec![1, 2, 3, 4, 5];
let two = vec![1, 2, 4, 6];
let mut patch = Vec::new();
bsdiff_android::diff(&one, &two, &mut patch).unwrap();
let mut patched = Vec::with_capacity(two.len());
bsdiff_android::patch(&one, &mut patch.as_slice(), &mut patched).unwrap();
assert_eq!(patched, two);
}§Diffing Files
fn diff_files(file_a: &str, file_b: &str, patch_file: &str) -> std::io::Result<()> {
let old = std::fs::read(file_a)?;
let new = std::fs::read(file_b)?;
let mut patch = Vec::new();
bsdiff_android::diff(&old, &new, &mut patch)?;
std::fs::write(patch_file, &patch)
}§Patching Files
fn patch_file(file_a: &str, patch_file: &str, file_b: &str) -> std::io::Result<()> {
let old = std::fs::read(file_a)?;
let patch = std::fs::read(patch_file)?;
let mut new = Vec::new();
bsdiff_android::patch(&old, &mut patch.as_slice(), &mut new)?;
std::fs::write(file_b, &new)
}§Android BSDF2 Format
use bsdiff_android::patch_bsdf2;
fn apply_android_ota(old: &[u8], patch: &[u8]) -> std::io::Result<Vec<u8>> {
let mut new = Vec::new();
patch_bsdf2(old, patch, &mut new)?;
Ok(new)
}§License
BSD-2-Clause
Based on Colin Percival’s bsdiff/bspatch algorithm.
Enums§
Functions§
- apply_
bsdf2_ patch - Apply a BSDF2 patch with full validation and optimizations
- apply_
patch - Apply a patch to an “old” file, returning the “new” file.
- diff
- Diff an “old” and a “new” file, returning a patch.
- patch
- Apply a patch to an “old” file, returning the “new” file.
- patch_
bsdf2 - Apply a BSDF2 patch with full validation and optimizations