mirror of
https://github.com/italicsjenga/ableton-rack-converter.git
synced 2024-11-26 00:51:31 +11:00
convert to pathbuf
This commit is contained in:
parent
37090d6945
commit
272e531f7d
|
@ -1,11 +1,11 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use ableton_rack_converter::{self, fixers};
|
use ableton_rack_converter::{self, fixers};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let file_load = String::from(".\\validation\\Utility11.adg");
|
let file_load = PathBuf::from(".\\validation\\Utility11.adg");
|
||||||
let xml_save = String::from(".\\exported_files\\Utility11_save.xml");
|
let file_save = PathBuf::from(".\\exported_files\\Utility11_save.adg");
|
||||||
let file_save = String::from(".\\exported_files\\Utility11_save.adg");
|
let mut device = ableton_rack_converter::load_adg(file_load);
|
||||||
let mut device = ableton_rack_converter::load_adg(&file_load);
|
|
||||||
fixers::traverse_children(&mut device);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use xml_dom::{level2::RefNode, parser};
|
||||||
|
|
||||||
pub mod fixers;
|
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 contents = File::open(filename).expect("failed to load file");
|
||||||
let xml = decompress(contents);
|
let xml = decompress(contents);
|
||||||
decode(&xml)
|
decode(&xml)
|
||||||
|
@ -28,13 +28,13 @@ fn decode(xml: &str) -> RefNode {
|
||||||
parser::read_xml(xml).expect("failed to parse xml")
|
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 xml = encode(dom);
|
||||||
let compressed = compress(&xml);
|
let compressed = compress(&xml);
|
||||||
fs::write(filename, compressed).expect("could not write file");
|
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);
|
let xml = encode(dom);
|
||||||
fs::write(filename, xml.as_bytes()).expect("could not write file");
|
fs::write(filename, xml.as_bytes()).expect("could not write file");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue