views:

371

answers:

6

Seems this would not be a deterministic thing, or is there a way to do this reliably?

+4  A: 

Reliable: unzip both, diff.

I have no idea if that answer's good enough for your use, but it works.

Devin Jeanpierre
I'm looking to avoid opening and expanding and diffing, it could be more expensive.
ApplePieIsGood
Unfortunately, it's the only reliable way to do it.
R. Bemrose
+3  A: 

If you're using gzip, you can do something like this:

# diff <(zcat file1.gz) <(zcat file2.gz)
eduffy
Well I need to do this programmatically, and I'm not running in a unix environment (unfortunately).
ApplePieIsGood
how is the solution in this answer not "programmatically" solving your problem?
hop
+1  A: 

Beyond compare has no problem with this.

Lieven
I wonder if they expand it behind the scenes and diff? That's the thing, hard to say with an app what it does.
ApplePieIsGood
I'm pretty sure they expand behind the scenes. They have to to be able to show a side-by-side diff of two files from the zip archives.
Lieven
A: 

Well, I imagine zdiff would be some use to you.

chaos
A: 

WinMerge (windows only) has lots of features and one of them is:

  • Archive file support using 7-Zip
Zaagmans
A: 

In general, you cannot avoid decompressing and then comparing. Different compressors will result in different DEFLATEd byte streams, which when INFLATEd result in the same original text. You cannot simply compare the DEFLATEd data, one to another. That will FAIL in some cases.

But in a ZIP scenario, there is a CRC32 calculated and stored for each entry. So if you want to check files, you can simply compare the stored CRC32 associated to each DEFLATEd stream, with the caveats on the uniqueness properties of the CRC32 hash. It may fit your needs to compare the FileName and the CRC.

You would need a ZIP library that reads zip files and exposes those things as properties on the "ZipEntry" object. DotNetZip will do that for .NET apps.

Cheeso