This commit is contained in:
Piotr Siuszko 2023-12-27 21:35:21 +01:00
parent f68aeca902
commit 30626bab1f
2 changed files with 9 additions and 7 deletions

2
Cargo.lock generated
View File

@ -225,7 +225,7 @@ checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lwa_unity_unpack"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"clap",
"flate2",

View File

@ -41,8 +41,8 @@ pub fn extract_archive(archive_path: &Path, extract_to: &Path) -> io::Result<()>
}
fn main() {
let args : Args = Args::parse();
let ignored_extensions = args.ignore_extensions.unwrap_or(vec![]);
let args: Args = Args::parse();
let ignored_extensions = args.ignore_extensions.unwrap_or_default();
let archive_path = Path::new(&args.input);
let tmp_dir = Path::new("./tmp_dir");
let output_dir = Path::new(&args.output);
@ -68,7 +68,7 @@ fn main() {
let root_file = entry.path();
let asset = entry.file_name().into_string().unwrap();
if root_file.is_dir() {
let mut real_path= String::new() ;
let mut real_path = String::new();
let mut extension = None;
let mut has_asset = false;
for sub_entry in fs::read_dir(root_file.clone()).unwrap() {
@ -82,17 +82,19 @@ fn main() {
match line {
Some(Ok(path)) => {
real_path = path;
if let Some(e) = Path::new(&real_path).extension().and_then(OsStr::to_str) {
if let Some(e) =
Path::new(&real_path).extension().and_then(OsStr::to_str)
{
extension = Some(String::from(e));
}
},
}
_ => continue,
}
} else if file_name == "asset" {
has_asset = true;
}
}
if has_asset && !ignored_extensions.contains(&extension.unwrap_or_default()){
if has_asset && !ignored_extensions.contains(&extension.unwrap_or_default()) {
mapping.insert(asset, real_path);
}
}