Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
StackOverflow:“最佳 Diff 工具?” 提到了一堆二进制补丁实用程序。
StackOverflow:“二进制差异和补丁实用程序” 提到了更多二进制补丁实用程序。
StackOverflow:“二进制差异工具?” 提到了更多二进制补丁实用程序。
但我认为所有这些都会遇到同样的问题:
对于大多数压缩工具,两个压缩文件的“第一部分”将是相同的,直到发生第一个更改为止。
两个压缩文件的“最后部分”将完全不同。
任何 diff 工具(不会通过将文件识别为压缩文件并解压缩来作弊)都会创建一个补丁文件,该文件或多或少是新文件“最后部分”的批量副本。
在您的例子中,新文件的“最后部分”显然大约有 7 MB 长。
“按推测,该补丁文件大小应为1MB。”你怎么可能知道呢?
给定两个压缩文件,diff 实用程序将生成一个比这些文件小不了多少的补丁文件。
正如利亚姆所说,您需要在压缩之前区分这些文件的原始版本。
或者等效地,您需要将 .dat 文件解压缩为临时文件,并对这些临时文件进行比较。
(您也可以选择使用任意数据压缩实用程序来压缩补丁文件)。
我无法告诉您如何解压缩 .dat 文件,因为我不知道您拥有多种 .dat 文件中的哪一种。
StackOverflow: "Best Diff Tool?" mentions a bunch of binary patch utilities.
StackOverflow: "Binary diff and patch utility" mentions a few more binary patch utilities.
StackOverflow: "Binary diff tool?" mentions yet more binary patch utilities.
But I think you will have the same problem with all of them:
With most compression tools, the "first part" of the two compressed files will be identical, up to the point where the first change occurred.
The "last part" of the two compressed files will be completely different.
Any diff tool (that doesn't cheat by recognizing the files as a compressed file and decompress them) will create a patch file that is more-or-less a bulk copy of the "last part" of the new file.
In your case, the "last part" of the new file is apparently about 7 MB long.
"supposedly, the said patch file should be of size 1MB." How could you possibly know that?
Given two compressed files, a diff utility will generate a patch file that is not much smaller than those files.
As Liam said, you need to diff the original versions of these files before compressing.
Or equivalently, you need to decompress your .dat files into temporary files, and diff those temporary files.
(Optionally, you could use any arbitrary data compression utility to compress your patch files).
I can't tell you how to decompress your .dat files, because I don't know which one of the many kinds of .dat files you have.
比较压缩格式时,必须先解压缩它们。
Xdelta 对某些格式自动执行此操作,例如 gzip,但可能不会对 .dat 执行此操作
When diffing compressed formats, you have to decompress them first.
Xdelta does this automatically for a few formats, such as gzip, but probably not for .dat