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),
|
||||
Upload,
|
||||
Scan,
|
||||
Extract(Map),
|
||||
Extract(PathBufList),
|
||||
Replace,
|
||||
Interactive,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
struct Map {
|
||||
id:u64,
|
||||
struct PathBufList {
|
||||
paths:Vec<std::path::PathBuf>
|
||||
}
|
||||
|
||||
#[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<std::path::PathBuf>) -> BoxResult<()>{
|
||||
let mut id = 0;
|
||||
//Construct allowed scripts
|
||||
let mut script_set = std::collections::HashSet::<String>::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),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user