it works?

This commit is contained in:
Alex Janka 2021-07-10 15:02:36 +10:00
parent 272e531f7d
commit ed06bcee8b
3 changed files with 13 additions and 5 deletions

View file

@ -10,7 +10,6 @@ fn main() {
path_str.push_str(loadpath.file_stem().unwrap().to_str().unwrap()); path_str.push_str(loadpath.file_stem().unwrap().to_str().unwrap());
path_str.push_str("-compressed.adg"); path_str.push_str("-compressed.adg");
let savepath = PathBuf::from(path_str); let savepath = PathBuf::from(path_str);
println!("{:?}", savepath);
ableton_rack_converter::compress_file(loadpath, savepath); ableton_rack_converter::compress_file(loadpath, savepath);
} }
} }

View file

@ -1,10 +1,20 @@
use std::path::PathBuf; use std::{env, path::PathBuf};
use ableton_rack_converter::{self, fixers}; use ableton_rack_converter::{self, fixers};
fn main() { fn main() {
let file_load = PathBuf::from(".\\validation\\Utility11.adg"); let args: Vec<String> = env::args().collect();
let file_save = PathBuf::from(".\\exported_files\\Utility11_save.adg"); if args.len() == 1 {
return;
}
let file_load = PathBuf::from(args[1].as_str());
if file_load.extension().expect("no extension") != "adg" {
return;
}
let mut path_str = String::from(".\\");
path_str.push_str(file_load.file_stem().unwrap().to_str().unwrap());
path_str.push_str("-live10.adg");
let file_save = PathBuf::from(path_str);
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_adg(&device, file_save); ableton_rack_converter::save_adg(&device, file_save);

View file

@ -3,7 +3,6 @@ use xml_dom::level2::{Attribute, Node, RefNode};
pub fn traverse_children(node: &mut RefNode) { pub fn traverse_children(node: &mut RefNode) {
if node.node_name().to_string() == "Ableton" { if node.node_name().to_string() == "Ableton" {
for (name, mut attribute) in node.attributes() { for (name, mut attribute) in node.attributes() {
println!("{}: {}", name, attribute);
match name.to_string().as_str() { match name.to_string().as_str() {
"MajorVersion" => attribute.set_value("5").unwrap(), "MajorVersion" => attribute.set_value("5").unwrap(),
"MinorVersion" => attribute.set_value("10.0_370").unwrap(), "MinorVersion" => attribute.set_value("10.0_370").unwrap(),