convert to pathbuf

This commit is contained in:
Alex Janka 2021-07-10 14:50:35 +10:00
parent 37090d6945
commit 272e531f7d
2 changed files with 9 additions and 9 deletions

View file

@ -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);
}

View file

@ -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");
}