#patch #diff #patching #patch-file #jojo

jojodiff

Rust library for handling JojoDiff files, a diff utility for binary files

3 releases

0.1.2 Nov 8, 2024
0.1.1 Nov 7, 2024
0.1.0 Nov 7, 2024

#447 in Filesystem

Download history 325/week @ 2024-11-04 55/week @ 2024-11-11 61/week @ 2024-11-18 20/week @ 2024-11-25 6/week @ 2024-12-02 51/week @ 2024-12-09

141 downloads per month

MIT license

29KB
613 lines

jojodiff-rs

Rust library for working with JojoDiff files

The original Jojos Binary Diff tool can be found at https://jojodiff.sourceforge.net/ and https://sourceforge.net/projects/jojodiff/

This library is a Rust implementation of the JojoDiff file format. It is intended to be used as a library for other Rust projects that need to work with JojoDiff files.

Currently, it only supports applying JojoDiff patch files to binary files.

Usage

cargo add jojodiff

Logging

This library uses the log crate for logging. See https://docs.rs/log/latest/log/ for more information on how to select a logger implementation and configuring it.

Running tests

cargo test

Running a single test with logging:

RUST_LOG=debug cargo test patch_copy_seq_3_times

JojoDiff patch file format

The JojoDiff patch file format is a binary stream containing operands that describe how to transform an original file into a destination file.

The stream consists of a series of
  <op> (<data> || <len>)
where
  <op>   = <ESC> (<MOD>||<INS>||<DEL>||<EQL>||<BKT>)
  <data> = <chr>||<ESC><ESC>
  <chr>  = any byte different from <ESC><MOD><INS><DEL><EQL> or <BKT>
  <ESC><ESC> yields one <ESC> byte

Where:

  • <ESC> (0xA7) escape: Indicates that the next byte is an operand.
  • <MOD> (0xA6) modify: Replaces bytes from the original file with bytes from the patch file.
  • <INS> (0xA5) insert: Inserts bytes from the patch file into the destination file.
  • <DEL> (0xA4) delete: Skips bytes from the original file.
  • <EQL> (0xA3) equal: Copies bytes from the original file to the destination file.
  • <BKT> (0xA2) backtrack: Seeks backwards in the original file.

Dependencies

~86KB