Erlang librsync wrapper
Evgeniy Khramtsov c2e4b0fff9 Change testing platform: 20.0 -> 20.2 6 months ago
c_src Do not forget to free() atom name 2 years ago
doc Initial code and doc 2 years ago
src Bump version to 1.1.0 1 year ago
test Make it possible to compute from raw iodata 2 years ago
.travis.yml Change testing platform: 20.0 -> 20.2 6 months ago
LICENSE Initial commit 2 years ago
Makefile Do not delete rsync.app.src on distclean 2 years ago
README.md Clarify the example a bit 1 year ago
configure Add *.app.src file 2 years ago
configure.ac Add *.app.src file 2 years ago
rebar.config.script Add xref check 2 years ago
vars.config.in Initial code and doc 2 years ago

README.md

Erlang librsync wrapper

Build Status

erlang-rsync is an Erlang wrapper of librsync library. It provides basic functions for direct file manipulations (sig/1, delta/2, etc) as well as low-level functions for fine-grained control (sig_init/0, delta_update/2, etc). The low-level interface is somewhat similar to the hashing functions from crypto module.

Building

Requirements

  • GNU Make.
  • GCC.
  • rebar.
  • librsync (runtime library and header files).
  • Erlang/OTP 17.1 or higher.

Installation

$ git clone git://github.com/zinid/erlang-rsync.git
$ cd erlang-rsync
$ ./configure
$ make

Usage

API

The whole API documentation is located in the doc directory and can be built using edoc

$ make doc

Example

Let's say we have two files: local_file and remote_file, and we want local_file to have the content of remote_file. We first generate the signature of local_file. The signature is written in sig_file:

> rsync:sig("local_file", "sig_file").
ok.

We then generate the delta from remote_file and sig_file. The delta is written in delta_file:

> rsync:delta("sig_file", "remote_file", "delta_file").
ok.

Finally, using delta_file and local_file we reconstruct remote_file. The result is written in new_local_file.

> rsync:patch("local_file", "delta_file", "new_local_file").
ok.

Now new_local_file is "equal" to remote_file.

> file:read_file("new_local_file") == file:read_file("remote_file").
true.

Limitation

For patch/2, patch/3 and patch_init/1 functions to work the whole content of the original file should be read into the memory. This is due to a limitation of librsync API and Erlang's NIF API. So don't use these functions for extremely large files.