ups

Crates.ioups
lib.rsups
version0.3.1
sourcesrc
created_at2021-06-27 19:47:58.827167
updated_at2021-10-29 16:34:50.350171
descriptionA rust implementaiton of a UPS file patcher
homepagehttps://gitlab.com/Laikar/ups-rs
repositoryhttps://gitlab.com/Laikar/ups-rs
max_upload_size
id415508
size33,391
Laikar (Laikar)

documentation

README

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:

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

//Loading the contents of the source and patch files
let mut  source_file_content: Vec<u8> = vec![];
let mut  patch_file_content: Vec<u8> = vec![];
let mut  source_file = File::open("path/to/source/file")?;
source_file.read_to_end(&mut source_file_content);
let mut patch_file = File::open("path/to/patch/file")?;
patch_file.read_to_end(&mut patch_file_content);

//Apply the patch
let patch = UpsPatch::load(&patch_file_content)?;
let patched_file_content = patch.apply(&source_file_content)?;
//Write the target to a file
let mut target_file = File::open("path/to/target/file")?;
target_file.write_all(&*patched_file_content);

Create UPS Patch

use ups::UpsPatch;
use std::fs::File;
use std::io::{Read, Write};
//Load the contents of the source and patch files
let mut  source_file_content: Vec<u8> = vec![];
let mut  target_file_content: Vec<u8> = vec![];
let mut  source_file = File::open("path/to/source/file")?;
source_file.read_to_end(&mut source_file_content);
let mut target_file = File::open("path/to/patch/file")?;
target_file.read_to_end(&mut target_file_content);

//Create the UpsPatch
let patch = UpsPatch::create(&source_file_content, &target_file_content);
//Write the patch to a file
let patch_file_content = patch.get_patch_file_contents();
let mut patch_file = File::open("path/to/target/file")?;
patch_file.write_all(&patch_file_content);

##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)

Commit count: 11

cargo fmt