tags:

views:

213

answers:

3

Hi! Usually both files are availble for running some diff tool but I need to find the differences in 2 binary files when one of them resides in the server and another is in the mobile device. Then only the different parts can be sent to the server and file updated.

A: 

To find the differences, you must compare. If you cannot compare, you cannot compute the minimal differences.

What kind of changes do you do to the local file?

  • Inserts?
  • Deletions?
  • Updates?

If only updates, ie. the size and location of unchanged data is constant, then a block-type checksum solution might work, where you split the file up into blocks, compute the checksum of each, and compare with a list of previous checksums. Then you only have to send the modified blocks.

Also, if possible, you could store two versions of the file locally, the old and modified.

Lasse V. Karlsen
Files can be anything that user has in his mobile phone: images, videos, databases.They are backed up regularly to the server
Riho
+1  A: 

You're probably using the name generically, because diff expects its arguments to be text files.

If given binary files, it can only say they're different, not what the differences are.

But you need to update only the modified parts of binary files.

This is how the Open Source program called Rsync works, but I'm not aware of any version running on mobile devices.

pavium
rsync runs on a jailbreaked iPhone.
nalply
+1  A: 

There is the bsdiff tool. Debian has a bsdiff package, too, and there are high-level programming language interfaces like python-bsdiff.

I think that a jailbreaked iPhone, Android or similar mobile device can run bsdiff, but maybe you have to compile the software yourself.

But note! If you use the binary diff only to decide which part of the file to update, better use rsync. rsync has a built-in binary diff algorithm.

nalply