diff --git a/src/main.rs b/src/main.rs index 04c9529..bcb04fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,14 +21,14 @@ enum Commands { Download(MapList), Upload, Scan, - Extract(Map), + Extract(PathBufList), Replace, Interactive, } #[derive(Args)] -struct Map { - id:u64, +struct PathBufList { + paths:Vec } #[derive(Args)] @@ -259,19 +259,15 @@ fn scan() -> BoxResult<()>{ std::fs::write("id",id.to_string())?; Ok(()) } -fn extract(file_id:u64) -> BoxResult<()>{ + +fn extract(paths: Vec) -> BoxResult<()>{ let mut id = 0; //Construct allowed scripts let mut script_set = std::collections::HashSet::::new(); - let file_id_string=file_id.to_string(); - - for entry in std::fs::read_dir("maps/unprocessed")? { - let file_thing=entry?; - if file_thing.file_name().to_str().unwrap().find(&file_id_string).is_none(){ - continue; - } - let input = std::io::BufReader::new(std::fs::File::open(file_thing.path())?); + for path in paths { + let file_name=path.file_name(); + let input = std::io::BufReader::new(std::fs::File::open(&path)?); let dom = rbx_binary::from_reader(input)?; @@ -285,11 +281,11 @@ fn extract(file_id:u64) -> BoxResult<()>{ continue; }else{ script_set.insert(s.clone()); - std::fs::write(format!("scripts/extracted/{:?}_{}_{}.lua",file_thing.file_name(),id,script.name),s)?; + std::fs::write(format!("scripts/extracted/{:?}_{}_{}.lua",file_name,id,script.name),s)?; id+=1; } }else{ - panic!("FATAL: failed to get source for {:?}",file_thing.file_name()); + panic!("FATAL: failed to get source for {:?}",file_name); } }else{ panic!("FATAL: failed to get_by_ref {:?}",script_ref); @@ -658,6 +654,6 @@ fn main() -> BoxResult<()> { Commands::Scan=>scan(), Commands::Replace=>replace(), Commands::Interactive=>interactive(), - Commands::Extract(map)=>extract(map.id), + Commands::Extract(pathlist)=>extract(pathlist.paths), } }