ups-rs

A rust implementation of a UPS file patcher.

I am no rust expert, and this was made for me to actually learn rust, feel free to open an issue pointing any mistake you find.

Usage

Apply UPS patch:

```rust use ups::UpsPatch; use std::fs::File; use std::io::{Read, Write};

//Loading the contents of the source and patch files let mut sourcefilecontent: Vec = vec![]; let mut patchfilecontent: Vec = vec![]; let mut sourcefile = File::open("path/to/source/file")?; sourcefile.readtoend(&mut sourcefilecontent); let mut patchfile = File::open("path/to/patch/file")?; patchfile.readtoend(&mut patchfilecontent);

//Apply the patch let patch = UpsPatch::load(&patchfilecontent)?; let patchedfilecontent = patch.apply(&sourcefilecontent)?; //Write the target to a file let mut targetfile = File::open("path/to/target/file")?; targetfile.writeall(&*patchedfile_content);

```

Create UPS Patch

```rust use ups::UpsPatch; use std::fs::File; use std::io::{Read, Write}; //Load the contents of the source and patch files let mut sourcefilecontent: Vec = vec![]; let mut targetfilecontent: Vec = vec![]; let mut sourcefile = File::open("path/to/source/file")?; sourcefile.readtoend(&mut sourcefilecontent); let mut targetfile = File::open("path/to/patch/file")?; targetfile.readtoend(&mut targetfilecontent);

//Create the UpsPatch let patch = UpsPatch::create(&sourcefilecontent, &targetfilecontent); //Write the patch to a file let patchfilecontent = patch.getpatchfilecontents(); let mut patchfile = File::open("path/to/target/file")?; patchfile.writeall(&patchfilecontent); ```

Documentation

The documentation is on docs.rs

Contributing:

Feel free to submit pull requests with improvements.

License

All files in this repository except UPS-spec.pdf and ups_spec.md are released under MIT License.

ups-spec.pdf is the original ups spec file released under Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0).

ups_spec.md is a conversion of the original ups-spec.pdf into a more github friendly format, and keeps the same license as the original, Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0)