**HDiffPatch**
================
[![release](https://img.shields.io/badge/release-v2.4.3-blue.svg)](https://github.com/sisong/HDiffPatch/releases) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls)
[![Build Status](https://travis-ci.org/sisong/HDiffPatch.svg?branch=master)](https://travis-ci.org/sisong/HDiffPatch) [![Build status](https://ci.appveyor.com/api/projects/status/t9ow8dft8lt898cv/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/hdiffpatch/branch/master)
a C\C++ library and command-line tools for binary data Diff & Patch.
( Jar or Zip file diff & patch? update Android Apk? try [ApkDiffPatch](https://github.com/sisong/ApkDiffPatch)! )
---
## command line usage:
**hdiffz** [-m[-matchScore]|-s[-matchBlockSize]] [-c-compressType[-compressLevel]] [-o] **oldFile newFile outDiffFile**
```
memory options:
-m-matchScore
all file load into Memory, with matchScore; DEFAULT; best diffFileSize;
requires (newFileSize+oldFileSize*5(or *9 when oldFileSize>=2GB))+O(1) bytes of memory;
matchScore>=0, DEFAULT 6, recommended bin: 0--4 text: 4--9 etc...
-s-matchBlockSize
all file load as Stream, with matchBlockSize; fast;
requires O(oldFileSize*16/matchBlockSize+matchBlockSize*5) bytes of memory;
matchBlockSize>=2, DEFAULT 128, recommended 32--16k 64k 1m etc...
special options:
-c-compressType-compressLevel
set diffFile Compress type & level, DEFAULT uncompress;
support compress type & level:
(reference: https://github.com/sisong/lzbench/blob/master/lzbench171_sorted.md )
-zlib[-{1..9}] DEFAULT level 9
-bzip2[-{1..9}] DEFAULT level 9
-lzma[-{0..9}[-dictSize]] DEFAULT level 7
dictSize(==decompress stream size) can like 4096 or 4k or 4m or 128m etc..., DEFAULT 4m
-lz4 no level
-lz4hc[-{3..12}] DEFAULT level 11
-zstd[-{0..22}] DEFAULT level 20
-o Original diff, unsupport run with -s or -c; DEPRECATED;
compatible with "diff_demo.cpp",
diffFile must patch by "patch_demo.c" or "hpatchz -o ..."
```
**hpatchz** [-m|-s[-cacheSize]] [-o] **oldFile diffFile outNewFile**
```
memory options:
-m oldFile all loaded into Memory; fast;
requires (oldFileSize + 4 * decompress stream size) + O(1) bytes of memory
-s-cacheSize
oldFile loaded as Stream, with cacheSize; DEFAULT;
requires (cacheSize + 4 * decompress stream size) + O(1) bytes of memory;
cacheSize can like 262144 or 256k or 512m or 2g etc..., DEFAULT 128m
special options:
-o Original patch; DEPRECATED; compatible with "patch_demo.c",
diffFile must created by "diff_demo.cpp" or "hdiffz -o ..."
```
---
## library API usage:
* **create_diff**(newData,oldData,out diffData);
release the diffData for update oldData.
`note:` create_diff() out **uncompressed** diffData;
you can compressed it by yourself or use **create_compressed_diff()**/patch_decompress() create **compressed** diffData;
if your file size very large or request faster and less memory requires, you can use **create_compressed_diff_stream()**/patch_decompress().
* bool **patch**(out newData,oldData,diffData);
ok , get the newData.
---
* **patch()** runs in O(oldSize+newSize) time , and requires (oldSize+newSize+diffSize)+O(1) bytes of memory;
**patch_stream()** requires O(1) bytes of memory;
**patch_decompress()** requires (4\*decompress stream size)+O(1) bytes of memory.
**create_diff()** & **create_compressed_diff()** runs in O(oldSize+newSize) time , and if oldSize \< 2G Byte then requires oldSize\*5+newSize+O(1) bytes of memory; if oldSize \>= 2G Byte then requires oldSize\*9+newSize+O(1) bytes of memory;
**create_compressed_diff_stream()** requires O(oldSize\*16/kMatchBlockSize+kMatchBlockSize\*5) bytes of memory.
---
### HDiffPatch vs BsDiff4.3:
system: macOS10.12.6, compiler: xcode8.3.3 x64, CPU: i7 2.5G(turbo3.7G,6MB L3 cache),SSD Disk,Memroy:8G*2 DDR3 1600MHz
(purge file cache before every test)
```
HDiffPatch2.4 hdiffz run by: -m -c-bzip2-9|-c-lzma-7-4m|-c-zlib-9 oldFile newFile outDiffFile
hpatchz run by: -m oldFile diffFile outNewFile
BsDiff4.3 with bzip2 and all data in memory;
(NOTE: when compiling BsDiff4.3-x64, suffix string index type int64 changed to int32,
faster and memroy requires to be halved!)
=======================================================================================================
Program Uncompressed Compressed Compressed BsDiff hdiffz
(newVersion<--oldVersion) (tar) (bzip2) (lzma) (bzip2) (bzip2 lzma zlib)
-------------------------------------------------------------------------------------------------------
apache-maven-2.2.1-src <--2.0.11 5150720 1213258 1175464 115723 83935 80997 91921
httpd_2.4.4-netware-bin <--2.2.24 22612480 4035904 3459747 2192308 1809555 1616435 1938953
httpd-2.4.4-src <-- 2.2.24 31809536 4775534 4141266 2492534 1882555 1717468 2084843
Firefox-21.0-mac-en-US.app<--20.0 98740736 39731352 33027837 16454403 15749937 14018095 15417854
emacs-24.3 <-- 23.4 185528320 42044895 33707445 12892536 9574423 8403235 10964939
eclipse-java-juno-SR2-macosx
-cocoa-x86_64 <--x86_32 178595840 156054144 151542885 1595465 1587747 1561773 1567700
gcc-src-4.8.0 <--4.7.0 552775680 86438193 64532384 11759496 8433260 7288783 9445004
-------------------------------------------------------------------------------------------------------
Average Compression 100.00% 31.76% 28.47% 6.64% 5.58% 5.01% 5.86%
=======================================================================================================
=======================================================================================================
Program run time(Second) memory(MB) run time(Second) memory(MB)
BsDiff hdiffz BsDiff hdiffz BsPatch hpatchz BsPatch hpatchz
(bzip2)(bzip2) (bzip2)(bzip2) (bzip2) (bzip2 lzma zlib) (bzip2) (bzip2 lzma zlib)
-------------------------------------------------------------------------------------------------------
apache-maven... 1.3 0.4 42 28 0.09 0.04 0.03 0.02 14 8 7 6
httpd bin... 8.6 3.0 148 124 0.72 0.36 0.18 0.13 50 24 23 18
httpd src... 20 5.1 322 233 0.99 0.46 0.24 0.17 78 44 42 37
Firefox... 94 28 829 582 3.0 2.2 1.2 0.57 198 106 106 94
emacs... 109 32 1400 1010 4.9 2.3 1.1 0.78 348 174 168 161
eclipse 100 33 1500 1000 1.5 0.56 0.57 0.50 350 176 174 172
gcc-src... 366 69 4420 3030 7.9 3.5 2.1 1.85 1020 518 517 504
-------------------------------------------------------------------------------------------------------
Average 100% 28.9% 100% 71.5% 100% 52.3% 29.9% 21.3% 100% 52.3% 50.3% 45.5%
=======================================================================================================
```
### HDiffPatch vs xdelta3.1:
```
HDiffPatch2.4 hdiffz run by: -s-128 -c-bzip2-9 oldFile newFile outDiffFile
hpatchz run by: -s-4m oldFile diffFile outNewFile
xdelta3.1 diff run by: -e -s old_file new_file delta_file
patch run by: -d -s old_file delta_file decoded_new_file
没有合适的资源?快使用搜索试试~ 我知道了~
hdiffpatch 差分环境包
共73个文件
h:26个
cpp:9个
xcworkspacedata:8个
5星 · 超过95%的资源 需积分: 50 26 下载量 19 浏览量
2018-11-30
14:26:35
上传
评论 2
收藏 171KB ZIP 举报
温馨提示
hdiffpatch 差分环境包, 用于OTA升级。
资源推荐
资源详情
资源评论
收起资源包目录
HDiffPatch-master.zip (73个子文件)
HDiffPatch-master
file_for_patch.h 8KB
builds
vc
HDiffZ.vcxproj 13KB
HDiffZ.vcxproj.user 143B
unitTest.vcxproj 8KB
unitTest.vcxproj.user 143B
HDiffPatch.sln 3KB
HPatchZ.vcxproj.user 143B
HPatchZ.vcxproj 11KB
xcode
lz4.xcodeproj
project.xcworkspace
contents.xcworkspacedata 148B
project.pbxproj 9KB
unitTest.xcodeproj
project.xcworkspace
contents.xcworkspacedata 153B
project.pbxproj 21KB
hdiffz.xcodeproj
project.xcworkspace
contents.xcworkspacedata 151B
project.pbxproj 23KB
hpatchz.xcodeproj
project.xcworkspace
contents.xcworkspacedata 151B
project.pbxproj 12KB
bestParams.xcodeproj
project.xcworkspace
contents.xcworkspacedata 155B
project.pbxproj 19KB
zstd.xcodeproj
project.xcworkspace
contents.xcworkspacedata 149B
project.pbxproj 28KB
HDiffPatch.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 756B
lzma.xcodeproj
project.xcworkspace
contents.xcworkspacedata 149B
project.pbxproj 9KB
codeblocks
HDiffZ.cbp 9KB
unitTest.cbp 2KB
HDiffPatch.workspace 281B
HPatchZ.cbp 6KB
hpatchz.c 13KB
_atosize.h 3KB
.travis.yml 1KB
LICENSE 1KB
test
unit_test.cpp 16KB
_private_searchBestParams.cpp 10KB
README.md 11KB
Makefile 3KB
decompress_plugin_demo.h 27KB
hdiffz.cpp 21KB
compress_plugin_demo.h 31KB
.gitignore 167B
libHDiffPatch
HDiff
private_diff
sais.hxx 19KB
libdivsufsort
trsort.c.inc.h 18KB
divsufsort64.h 6KB
sssort.c.inc.h 24KB
utils.c.inc.h 10KB
divsufsort.c.inc.h 12KB
divsufsort_private.h 6KB
divsufsort.c 278B
divsufsort64.c 306B
config.h 2KB
divsufsort.h 6KB
bytes_rle.cpp 4KB
limit_mem_diff
stream_serialize.h 5KB
covers.h 2KB
digest_matcher.cpp 26KB
adler_roll.h 4KB
digest_matcher.h 2KB
stream_serialize.cpp 13KB
bloom_filter.h 5KB
adler_roll.c 8KB
compress_detect.h 3KB
suffix_string.cpp 13KB
compress_detect.cpp 6KB
pack_uint.h 2KB
bytes_rle.h 2KB
suffix_string.h 3KB
diff.cpp 33KB
diff.h 4KB
diff_types.h 3KB
HPatch
patch_types.h 7KB
patch.h 7KB
patch.c 81KB
_clock_for_demo.h 2KB
共 73 条
- 1
资源评论
- 骄傲被梦想打碎2020-05-25很不错,很实用!
wsdl-king
- 粉丝: 22
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功