diff --git a/src/bin/converter.rs b/src/bin/converter.rs index a229cdd..b19c413 100644 --- a/src/bin/converter.rs +++ b/src/bin/converter.rs @@ -1,11 +1,11 @@ +use std::path::PathBuf; + use ableton_rack_converter::{self, fixers}; fn main() { - let file_load = String::from(".\\validation\\Utility11.adg"); - let xml_save = String::from(".\\exported_files\\Utility11_save.xml"); - let file_save = String::from(".\\exported_files\\Utility11_save.adg"); - let mut device = ableton_rack_converter::load_adg(&file_load); + let file_load = PathBuf::from(".\\validation\\Utility11.adg"); + let file_save = PathBuf::from(".\\exported_files\\Utility11_save.adg"); + let mut device = ableton_rack_converter::load_adg(file_load); fixers::traverse_children(&mut device); - ableton_rack_converter::save_uncompressed(&device, &xml_save); - ableton_rack_converter::save_adg(&device, &file_save); + ableton_rack_converter::save_adg(&device, file_save); } diff --git a/src/lib.rs b/src/lib.rs index e84770b..4ffde4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ use xml_dom::{level2::RefNode, parser}; pub mod fixers; -pub fn load_adg(filename: &str) -> RefNode { +pub fn load_adg(filename: PathBuf) -> RefNode { let contents = File::open(filename).expect("failed to load file"); let xml = decompress(contents); decode(&xml) @@ -28,13 +28,13 @@ fn decode(xml: &str) -> RefNode { parser::read_xml(xml).expect("failed to parse xml") } -pub fn save_adg(dom: &RefNode, filename: &str) { +pub fn save_adg(dom: &RefNode, filename: PathBuf) { let xml = encode(dom); let compressed = compress(&xml); fs::write(filename, compressed).expect("could not write file"); } -pub fn save_uncompressed(dom: &RefNode, filename: &str) { +pub fn save_uncompressed(dom: &RefNode, filename: PathBuf) { let xml = encode(dom); fs::write(filename, xml.as_bytes()).expect("could not write file"); }