forked from StrafesNET/asset-tool
misc tweaks + tweak Query objects + remove ScriptHint::Undetermined
This commit is contained in:
parent
e5c7ed6b75
commit
17bfbef482
59
src/main.rs
59
src/main.rs
@ -1125,25 +1125,30 @@ type QueryHintResult=Result<FileHint,QueryResolveError>;
|
|||||||
trait Query{
|
trait Query{
|
||||||
async fn resolve(self)->QueryHintResult;
|
async fn resolve(self)->QueryHintResult;
|
||||||
}
|
}
|
||||||
struct QuerySingle(tokio::task::JoinHandle<Result<tokio::fs::File,QueryResolveError>>);
|
type QueryHandle=tokio::task::JoinHandle<Result<tokio::fs::File,QueryResolveError>>;
|
||||||
|
struct QuerySingle{
|
||||||
|
script:QueryHandle,
|
||||||
|
}
|
||||||
impl QuerySingle{
|
impl QuerySingle{
|
||||||
fn rox(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
fn rox(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
||||||
Self(tokio::spawn(get_file_async(search_path.clone(),format!("{}.lua",search_name))))
|
Self{
|
||||||
|
script:tokio::spawn(get_file_async(search_path.clone(),format!("{}.lua",search_name)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Query for QuerySingle{
|
impl Query for QuerySingle{
|
||||||
async fn resolve(self)->QueryHintResult{
|
async fn resolve(self)->QueryHintResult{
|
||||||
match self.0.await{
|
match self.script.await{
|
||||||
Ok(Ok(file))=>Ok(FileHint{file,hint:ScriptHint::Undetermined}),
|
Ok(Ok(file))=>Ok(FileHint{file,hint:ScriptHint::ModuleScript}),
|
||||||
Ok(Err(e))=>Err(e),
|
Ok(Err(e))=>Err(e),
|
||||||
Err(e)=>Err(QueryResolveError::JoinError(e)),
|
Err(e)=>Err(QueryResolveError::JoinError(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct QueryTriple{
|
struct QueryTriple{
|
||||||
module:QuerySingle,
|
module:QueryHandle,
|
||||||
server:QuerySingle,
|
server:QueryHandle,
|
||||||
client:QuerySingle,
|
client:QueryHandle,
|
||||||
}
|
}
|
||||||
impl QueryTriple{
|
impl QueryTriple{
|
||||||
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str,search_module:bool)->Self{
|
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str,search_module:bool)->Self{
|
||||||
@ -1154,9 +1159,9 @@ impl QueryTriple{
|
|||||||
format!("{}.lua",search_name)
|
format!("{}.lua",search_name)
|
||||||
};
|
};
|
||||||
Self{
|
Self{
|
||||||
module:QuerySingle(tokio::spawn(get_file_async(search_path.clone(),module_name))),
|
module:tokio::spawn(get_file_async(search_path.clone(),module_name)),
|
||||||
server:QuerySingle(tokio::spawn(get_file_async(search_path.clone(),format!("{}.server.lua",search_name)))),
|
server:tokio::spawn(get_file_async(search_path.clone(),format!("{}.server.lua",search_name))),
|
||||||
client:QuerySingle(tokio::spawn(get_file_async(search_path.clone(),format!("{}.client.lua",search_name)))),
|
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:&std::path::PathBuf)->Self{
|
||||||
@ -1214,7 +1219,7 @@ fn mega_quadruple_join(query_quad:(QueryHintResult,QueryHintResult,QueryHintResu
|
|||||||
}
|
}
|
||||||
impl Query for QueryTriple{
|
impl Query for QueryTriple{
|
||||||
async fn resolve(self)->QueryHintResult{
|
async fn resolve(self)->QueryHintResult{
|
||||||
let (module,server,client)=tokio::join!(self.module.0,self.server.0,self.client.0);
|
let (module,server,client)=tokio::join!(self.module,self.server,self.client);
|
||||||
mega_triple_join((
|
mega_triple_join((
|
||||||
module.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
module.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
||||||
server.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::Script}),
|
server.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::Script}),
|
||||||
@ -1223,16 +1228,16 @@ impl Query for QueryTriple{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct QueryQuad{
|
struct QueryQuad{
|
||||||
module_implicit:QuerySingle,
|
module_implicit:QueryHandle,
|
||||||
module_explicit:QuerySingle,
|
module_explicit:QueryHandle,
|
||||||
server:QuerySingle,
|
server:QueryHandle,
|
||||||
client:QuerySingle,
|
client:QueryHandle,
|
||||||
}
|
}
|
||||||
impl QueryQuad{
|
impl QueryQuad{
|
||||||
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
fn rox_rojo(search_path:&std::path::PathBuf,search_name:&str)->Self{
|
||||||
let fill=QueryTriple::rox_rojo(search_path,search_name,true);
|
let fill=QueryTriple::rox_rojo(search_path,search_name,true);
|
||||||
Self{
|
Self{
|
||||||
module_implicit:QuerySingle::rox(search_path,search_name),//Script.lua
|
module_implicit:QuerySingle::rox(search_path,search_name).script,//Script.lua
|
||||||
module_explicit:fill.module,//Script.module.lua
|
module_explicit:fill.module,//Script.module.lua
|
||||||
server:fill.server,
|
server:fill.server,
|
||||||
client:fill.client,
|
client:fill.client,
|
||||||
@ -1241,7 +1246,7 @@ impl QueryQuad{
|
|||||||
}
|
}
|
||||||
impl Query for QueryQuad{
|
impl Query for QueryQuad{
|
||||||
async fn resolve(self)->QueryHintResult{
|
async fn resolve(self)->QueryHintResult{
|
||||||
let (module_implicit,module_explicit,server,client)=tokio::join!(self.module_implicit.0,self.module_explicit.0,self.server.0,self.client.0);
|
let (module_implicit,module_explicit,server,client)=tokio::join!(self.module_implicit,self.module_explicit,self.server,self.client);
|
||||||
mega_quadruple_join((
|
mega_quadruple_join((
|
||||||
module_implicit.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
module_implicit.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
||||||
module_explicit.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
module_explicit.map_err(|e|QueryResolveError::JoinError(e))?.map(|file|FileHint{file,hint:ScriptHint::ModuleScript}),
|
||||||
@ -1287,7 +1292,7 @@ async fn script_node(search_name:&str,mut file:tokio::fs::File,hint:ScriptHint)-
|
|||||||
name:script_with_overrides.overrides.name.unwrap_or_else(||search_name.to_owned()),
|
name:script_with_overrides.overrides.name.unwrap_or_else(||search_name.to_owned()),
|
||||||
class:match (script_with_overrides.overrides.class.as_deref(),hint){
|
class:match (script_with_overrides.overrides.class.as_deref(),hint){
|
||||||
(Some("ModuleScript"),_)
|
(Some("ModuleScript"),_)
|
||||||
|(None,ScriptHint::ModuleScript|ScriptHint::Undetermined)=>CompileClass::ModuleScript(script_with_overrides.source),
|
|(None,ScriptHint::ModuleScript)=>CompileClass::ModuleScript(script_with_overrides.source),
|
||||||
(Some("LocalScript"),_)
|
(Some("LocalScript"),_)
|
||||||
|(None,ScriptHint::Script)=>CompileClass::LocalScript(script_with_overrides.source),
|
|(None,ScriptHint::Script)=>CompileClass::LocalScript(script_with_overrides.source),
|
||||||
(Some("Script"),_)
|
(Some("Script"),_)
|
||||||
@ -1308,18 +1313,9 @@ async fn model_node(search_name:&str,mut file:tokio::fs::File)->AResult<CompileN
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn discern_node(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<Option<CompileNode>>{
|
async fn locate_override_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->AResult<Option<CompileNode>>{
|
||||||
let contents_folder=entry.path();
|
let contents_folder=entry.path();
|
||||||
let file_name=entry.file_name();
|
let file_name=entry.file_name();
|
||||||
//is folder? else exit flow control
|
|
||||||
match tokio::fs::read_dir(contents_folder.as_path()).await{
|
|
||||||
Ok(_)=>(),//continue flow
|
|
||||||
Err(e)=>{println!("{:?}",e.raw_os_error());match e.raw_os_error(){
|
|
||||||
Some(0)//std::io::ErrorKind::NotFound
|
|
||||||
|Some(20)=>return Ok(None),//std::io::ErrorKind::NotADirectory (not allowed to be used but returns it anyways)
|
|
||||||
_=>Err(e)?,
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
let search_name=file_name.to_str().unwrap();
|
let search_name=file_name.to_str().unwrap();
|
||||||
//scan inside the folder for an object to define the class of the folder
|
//scan inside the folder for an object to define the class of the folder
|
||||||
let script_query=async {match style{
|
let script_query=async {match style{
|
||||||
@ -1362,8 +1358,8 @@ async fn discern_file(entry:&tokio::fs::DirEntry,style:Option<DecompileStyle>)->
|
|||||||
let path=entry.path();
|
let path=entry.path();
|
||||||
let file_discernment=match path.extension(){
|
let file_discernment=match path.extension(){
|
||||||
Some(extension)=>match extension.to_str(){
|
Some(extension)=>match extension.to_str(){
|
||||||
Some("lua")=>FileDiscernment::Script(ScriptHint::Undetermined),
|
Some("lua")
|
||||||
Some("module.lua")=>FileDiscernment::Script(ScriptHint::ModuleScript),
|
|Some("module.lua")=>FileDiscernment::Script(ScriptHint::ModuleScript),
|
||||||
Some("client.lua")=>FileDiscernment::Script(ScriptHint::LocalScript),
|
Some("client.lua")=>FileDiscernment::Script(ScriptHint::LocalScript),
|
||||||
Some("server.lua")=>FileDiscernment::Script(ScriptHint::Script),
|
Some("server.lua")=>FileDiscernment::Script(ScriptHint::Script),
|
||||||
Some("rbxmx")=>FileDiscernment::Model,
|
Some("rbxmx")=>FileDiscernment::Model,
|
||||||
@ -1391,7 +1387,6 @@ enum ScriptHint{
|
|||||||
Script,
|
Script,
|
||||||
LocalScript,
|
LocalScript,
|
||||||
ModuleScript,
|
ModuleScript,
|
||||||
Undetermined,
|
|
||||||
}
|
}
|
||||||
struct FileHint{
|
struct FileHint{
|
||||||
file:tokio::fs::File,
|
file:tokio::fs::File,
|
||||||
@ -1485,7 +1480,7 @@ async fn compile(config:CompileConfig)->AResult<()>{
|
|||||||
join_set.spawn(async move{
|
join_set.spawn(async move{
|
||||||
let met=entry.metadata().await?;
|
let met=entry.metadata().await?;
|
||||||
let scooby_doo=if met.is_dir(){
|
let scooby_doo=if met.is_dir(){
|
||||||
discern_node(&entry,style).await
|
locate_override_file(&entry,style).await
|
||||||
}else{
|
}else{
|
||||||
discern_file(&entry,style).await
|
discern_file(&entry,style).await
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user