PatchSet only serializes patches
to the file.
This commit is contained in:
parent
4cbc70eeca
commit
975d6fd420
|
@ -49,8 +49,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
patches.add_patches(rom_patches);
|
patches.add_patches(rom_patches);
|
||||||
|
|
||||||
println!("Writing output file {}", output_path);
|
println!("Writing output file {}", output_path);
|
||||||
let out_file = File::create(&output_path)?;
|
patches.save_to_file(Path::new(&output_path))?;
|
||||||
serde_json::to_writer(out_file, &patches)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub struct Patch {
|
||||||
pub patch_data: Vec<u8>,
|
pub patch_data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
pub struct PatchSet {
|
pub struct PatchSet {
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
patches: Vec<Patch>,
|
patches: Vec<Patch>,
|
||||||
|
@ -43,6 +42,22 @@ impl PatchSet {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn save(&self) -> anyhow::Result<()> {
|
||||||
|
let file = File::create(&self.filename)?;
|
||||||
|
let buffer = std::io::BufWriter::new(file);
|
||||||
|
serde_json::to_writer(buffer, &self.patches)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_to_file(&self, filename: &Path) -> anyhow::Result<()> {
|
||||||
|
let file = File::create(filename)?;
|
||||||
|
let buffer = std::io::BufWriter::new(file);
|
||||||
|
serde_json::to_writer(buffer, &self.patches)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_patch(&mut self, patch: Patch) {
|
pub fn add_patch(&mut self, patch: Patch) {
|
||||||
self.patches.push(patch);
|
self.patches.push(patch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue