BSDiff.bsdiffFunction
bsdiff(old, new, [ patch ]; format = [ :classic | :endsley ]) -> patch

Compute a binary patch that will transform the content of old into the content of new. All arguments can be strings or IO handles. If no patch argument is provided, the patch data is written to a temporary file whose path is returned.

The old argument can also be a 2-tuple of strings and/or IO handles, in which case the first is used as the old data and the second is used as a precomputed index of the old data, as computed by bsindex. Since indexing the old data is the slowest part of generating a diff, precomputing this and reusing it can significantly speed up generting diffs from the same old file to multiple different new files.

The format keyword argument allows selecting a patch format to generate. The value must be one of the symbols :classic or :endsley indicating a bsdiff patch format. The classic patch format is generated by default, but the Endsley format can be selected with bsdiff(old, new, patch, format = :endsley).

BSDiff.bsindexFunction
bsindex(old, [ index ]) -> index

Save index data (a sorted suffix array) for the content of old into index. All arguments can be strings or IO handles. If no index argument is provided, the index data is saved to a temporary file whose path is returned.

The index can be passed to bsdiff to speed up the diff computation by passing (old, index) as the first argument instead of just old. Since indexing the old data is the slowest part of generating a diff, precomputing this and reusing it can significantly speed up generting diffs from the same old file to multiple different new files.

BSDiff.bspatchMethod
bspatch(old, [ new, ] patch; format = [ :classic | :endsley ]) -> new

Apply a binary patch given by the patch argument to the content of old to produce the content of new. All arguments can be strings or IO handles. If no new argument is provided, the new data is written to a temporary file whose path is returned.

Note that the optional argument is the middle argument, which is a bit unusual but makes the argument order when passing all three paths consistent with the bspatch command and with the bsdiff function.

By default bspatch auto-detects the patch format, so the format keyword argument is usually unnecessary. If you wish to restrict the format of patch that will be accepted, however, you can use this keyword argument: bspatch will raise an error unless the patch file has indicated format.

BSDiff.apply_patchFunction

Apply a patch stream to the old data buffer, emitting a new data stream.

BSDiff.generate_patchFunction

Computes and emits the diff of the byte vectors new versus old. The index array is a zero-based suffix array of old.

BSDiff.prefix_searchMethod

Search for the longest prefix of new[t:end] in old. Uses the suffix array of old to search efficiently.

BSDiff.strcmplenMethod

Return lexicographic order and length of common prefix.