首页
/ HDiffPatch 技术文档

HDiffPatch 技术文档

2024-12-28 12:00:52作者:范靓好Udolf

本文档旨在帮助用户详细了解并使用 HDiffPatch 项目。以下是项目的安装指南、使用说明以及 API 使用文档。

1. 安装指南

二进制发布包

GitHub Release 下载适用于 Windows、Linux、MacOS 的命令行程序。对于安卓平台,下载 .so 库文件。

自己编译

Linux 或 MacOS X

  1. 进入 HDiffPatch 目录。

  2. 根据需要,选择以下编译选项:

    • 不启用任何压缩算法:make LDEF=0 LZMA=0 ZSTD=0 MD5=0
    • 启用默认编译设置:make

    如果遇到 bzip2 编译错误,安装 libbz2:

    git clone https://github.com/sisong/bzip2.git ../bzip2
    make LDEF=0 LZMA=0 ZSTD=0 MD5=0 BZIP2=1
    

    如果需要支持 lzma、zstd 和 md5 等,下载相应的库源码并编译:

    git clone https://github.com/sisong/libmd5.git ../libmd5
    git clone https://github.com/sisong/lzma.git ../lzma
    git clone https://github.com/sisong/zstd.git ../zstd
    git clone https://github.com/sisong/zlib.git ../zlib
    git clone https://github.com/sisong/libdeflate.git ../libdeflate
    make
    

    可以使用 make -j 来并行编译。

Windows

  1. 使用 Visual Studio 打开 builds/vc/HDiffPatch.sln

  2. 将第三方库下载到同级文件夹中:

    git clone https://github.com/sisong/libmd5.git ../libmd5
    git clone https://github.com/sisong/lzma.git ../lzma
    git clone https://github.com/sisong/zstd.git ../zstd
    git clone https://github.com/sisong/zlib.git ../zlib
    git clone https://github.com/sisong/libdeflate.git ../libdeflate
    git clone https://github.com/sisong/bzip2.git  ../bzip2
    

libhpatchz.so for Android

  1. 安装 Android NDK
  2. 进入 HDiffPatch/builds/android_ndk_jni_mk 目录。
  3. 执行 build_libs.sh(Windows 下执行 build_libs.bat)。
  4. 在安卓项目中添加 com/github/sisong/HPatch.java 和 .so 文件。

2. 项目使用说明

diff 命令行用法

创建新旧版本间的补丁:

hdiffz [options] oldPath newPath outDiffFile

压缩一个文件或文件夹:

hdiffz [-c-...] "" newPath outDiffFile

测试补丁是否正确:

hdiffz -t oldPath newPath testDiffFile

补丁使用新的压缩插件另存:

hdiffz [-c-...] diffFile outDiffFile

显示补丁的信息:

hdiffz -info diffFile

创建校验清单:

hdiffz [-g#...] [-C-checksumType] newPath -M#outManifestTxtFile

校验后创建补丁:

hdiffz [options] -M-old#oldManifestFile -M-new#newManifestFile oldPath newPath outDiffFile

patch 命令行用法

打补丁:

hpatchz [options] oldPath diffFile outNewPath

解压缩一个文件或文件夹:

hpatchz [options] "" diffFile outNewPath

显示补丁的信息:

hpatchz -info diffFile

创建自释放包:

hpatchz [-X-exe#selfExecuteFile] diffFile -X#outSelfExtractArchive

执行自释放包:

selfExtractArchive [options] oldPath -X outNewPath

3. 项目 API 使用文档

HDiffPatch 提供了丰富的命令行参数,具体用法和参数说明已在上述使用说明中详细列出。用户可以根据自己的需求选择合适的参数来创建补丁或打补丁。


以上是 HDiffPatch 的技术文档,希望对用户使用该项目有所帮助。

登录后查看全文
热门项目推荐
相关项目推荐