From b64da4511c03ceea8cc58943650543810671768e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 8 Mar 2024 09:48:47 -0800 Subject: [PATCH] import PathBuf --- src/main.rs | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main.rs b/src/main.rs index dac7c2a..288dac7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::io::Read; +use std::{io::Read,path::PathBuf}; use clap::{Args,Parser,Subcommand}; use anyhow::Result as AResult; use futures::StreamExt; @@ -6,7 +6,7 @@ use rbx_dom_weak::types::Ref; use tokio::io::AsyncReadExt; type AssetID=u64; -type AssetIDFileMap=Vec<(AssetID,std::path::PathBuf)>; +type AssetIDFileMap=Vec<(AssetID,PathBuf)>; const CONCURRENT_DECODE:usize=8; const CONCURRENT_REQUESTS:usize=32; @@ -25,7 +25,7 @@ struct Cli{ #[arg(long)] cookie_env:Option, #[arg(long)] - cookie_file:Option, + cookie_file:Option, //TODO: read the versions.json file instead of doing this //TODO: write file dates instead of versions.json #[arg(long)] @@ -52,10 +52,10 @@ struct Cli{ git_committer_email:Option, #[arg(short,long)] - input:Option, + input:Option, #[arg(short,long)] - output:Option, + output:Option, #[command(subcommand)] command:Commands, @@ -86,7 +86,7 @@ struct AssetIDList{ #[derive(Args)] struct PathBufList{ - paths:Vec + paths:Vec } #[derive(serde::Deserialize)] @@ -205,7 +205,7 @@ async fn main()->AResult<()>{ enum Cookie{ Literal(String), Environment(String), - File(std::path::PathBuf), + File(PathBuf), } enum ReaderType{ @@ -380,7 +380,7 @@ struct DownloadHistoryConfig{ continue_from_versions:bool, end_version:Option, start_version:u64, - output_folder:std::path::PathBuf, + output_folder:PathBuf, cookie:String, asset_id:AssetID, } @@ -598,7 +598,7 @@ fn sanitize<'a>(s:&'a str)->std::borrow::Cow<'a,str>{ lazy_regex::regex!(r"[^A-z0-9.-]").replace_all(s,"_") } -fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:std::path::PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{ +fn write_item(dom:&rbx_dom_weak::WeakDom,mut file:PathBuf,node:&TreeNode,node_name_override:String,mut properties:PropertiesOverride,style:DecompileStyle,write_models:bool,write_scripts:bool)->AResult<()>{ file.push(sanitize(node_name_override.as_str()).as_ref()); match node.class{ Class::Folder=>(), @@ -759,7 +759,7 @@ fn generate_decompiled_context(input:R)->AResult{ struct WriteConfig{ style:DecompileStyle, - output_folder:std::path::PathBuf, + output_folder:PathBuf, write_template:bool, write_models:bool, write_scripts:bool, @@ -866,8 +866,8 @@ async fn write_files(config:WriteConfig,mut context:DecompiledContext)->AResult< struct DecompileConfig{ style:DecompileStyle, - input_file:std::path::PathBuf, - output_folder:std::path::PathBuf, + input_file:PathBuf, + output_folder:PathBuf, write_template:bool, write_models:bool, write_scripts:bool, @@ -899,7 +899,7 @@ async fn decompile(config:DecompileConfig)->AResult<()>{ struct WriteCommitConfig{ git_committer_name:String, git_committer_email:String, - output_folder:std::path::PathBuf, + output_folder:PathBuf, style:DecompileStyle, write_template:bool, write_models:bool, @@ -990,9 +990,9 @@ async fn write_commit(config:WriteCommitConfig,b:Result)->Result{ +async fn get_file_async(mut path:PathBuf,file_name:impl AsRef)->Result{ let name=file_name.as_ref().to_str().unwrap().to_owned(); path.push(file_name); match tokio::fs::File::open(path).await{ @@ -1139,7 +1139,7 @@ struct QuerySingle{ script:QueryHandle, } impl QuerySingle{ - fn rox(search_path:&std::path::PathBuf,search_name:&str)->Self{ + fn rox(search_path:&PathBuf,search_name:&str)->Self{ Self{ script:tokio::spawn(get_file_async(search_path.clone(),format!("{}.lua",search_name))) } @@ -1160,7 +1160,7 @@ struct QueryTriple{ client:QueryHandle, } impl QueryTriple{ - fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str,search_module:bool)->Self{ + fn rox_rojo(search_path:&PathBuf,search_name:&str,search_module:bool)->Self{ //this should be implemented as constructors of Triplet and Quadruplet to fully support Trey's suggestion let module_name=if search_module{ format!("{}.module.lua",search_name) @@ -1173,7 +1173,7 @@ impl QueryTriple{ client:tokio::spawn(get_file_async(search_path.clone(),format!("{}.client.lua",search_name))), } } - fn rojo(search_path:&std::path::PathBuf)->Self{ + fn rojo(search_path:&PathBuf)->Self{ QueryTriple::rox_rojo(search_path,"init",false) } } @@ -1243,7 +1243,7 @@ struct QueryQuad{ client:QueryHandle, } impl QueryQuad{ - fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str)->Self{ + fn rox_rojo(search_path:&PathBuf,search_name:&str)->Self{ let fill=QueryTriple::rox_rojo(search_path,search_name,true); Self{ module_implicit:QuerySingle::rox(search_path,search_name).script,//Script.lua @@ -1452,9 +1452,9 @@ enum CompileStackInstruction{ } struct CompileConfig{ - input_folder:std::path::PathBuf, - output_file:std::path::PathBuf, - template:Option, + input_folder:PathBuf, + output_file:PathBuf, + template:Option, style:Option, }