forked from StrafesNET/map-tool
switch extract to pathbuf
This commit is contained in:
parent
6efa811eb6
commit
9904b7a044
26
src/main.rs
26
src/main.rs
@ -21,14 +21,14 @@ enum Commands {
|
|||||||
Download(MapList),
|
Download(MapList),
|
||||||
Upload,
|
Upload,
|
||||||
Scan,
|
Scan,
|
||||||
Extract(Map),
|
Extract(PathBufList),
|
||||||
Replace,
|
Replace,
|
||||||
Interactive,
|
Interactive,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
struct Map {
|
struct PathBufList {
|
||||||
id:u64,
|
paths:Vec<std::path::PathBuf>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
@ -259,19 +259,15 @@ fn scan() -> BoxResult<()>{
|
|||||||
std::fs::write("id",id.to_string())?;
|
std::fs::write("id",id.to_string())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn extract(file_id:u64) -> BoxResult<()>{
|
|
||||||
|
fn extract(paths: Vec<std::path::PathBuf>) -> BoxResult<()>{
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
//Construct allowed scripts
|
//Construct allowed scripts
|
||||||
let mut script_set = std::collections::HashSet::<String>::new();
|
let mut script_set = std::collections::HashSet::<String>::new();
|
||||||
|
|
||||||
let file_id_string=file_id.to_string();
|
for path in paths {
|
||||||
|
let file_name=path.file_name();
|
||||||
for entry in std::fs::read_dir("maps/unprocessed")? {
|
let input = std::io::BufReader::new(std::fs::File::open(&path)?);
|
||||||
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())?);
|
|
||||||
|
|
||||||
let dom = rbx_binary::from_reader(input)?;
|
let dom = rbx_binary::from_reader(input)?;
|
||||||
|
|
||||||
@ -285,11 +281,11 @@ fn extract(file_id:u64) -> BoxResult<()>{
|
|||||||
continue;
|
continue;
|
||||||
}else{
|
}else{
|
||||||
script_set.insert(s.clone());
|
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;
|
id+=1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
panic!("FATAL: failed to get source for {:?}",file_thing.file_name());
|
panic!("FATAL: failed to get source for {:?}",file_name);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
panic!("FATAL: failed to get_by_ref {:?}",script_ref);
|
panic!("FATAL: failed to get_by_ref {:?}",script_ref);
|
||||||
@ -658,6 +654,6 @@ fn main() -> BoxResult<()> {
|
|||||||
Commands::Scan=>scan(),
|
Commands::Scan=>scan(),
|
||||||
Commands::Replace=>replace(),
|
Commands::Replace=>replace(),
|
||||||
Commands::Interactive=>interactive(),
|
Commands::Interactive=>interactive(),
|
||||||
Commands::Extract(map)=>extract(map.id),
|
Commands::Extract(pathlist)=>extract(pathlist.paths),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user