copy meta files alongside regular files, v0.3.0
This commit is contained in:
parent
a9426fc3b9
commit
ef54eef2e0
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## [0.3.0]
|
## [0.3.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- New flag `--copy-meta-files` for copying meta files alongside assets.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Multithreaded unpacking improvements.
|
- Multithreaded unpacking improvements.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lwa_unity_unpack"
|
name = "lwa_unity_unpack"
|
||||||
version = "0.2.1"
|
version = "0.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
repository = "https://github.com/Leinnan/lwa_unity_unpack"
|
repository = "https://github.com/Leinnan/lwa_unity_unpack"
|
||||||
homepage = "https://github.com/Leinnan/lwa_unity_unpack"
|
homepage = "https://github.com/Leinnan/lwa_unity_unpack"
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ Options:
|
||||||
-f, --fbx-to-gltf <FBX_TO_GLTF> optional- path to the tool that will auto convert fbx files to gltf during unpacking
|
-f, --fbx-to-gltf <FBX_TO_GLTF> optional- path to the tool that will auto convert fbx files to gltf during unpacking
|
||||||
--ignore-extensions <IGNORE_EXTENSIONS>
|
--ignore-extensions <IGNORE_EXTENSIONS>
|
||||||
optional- extensions that will be ignored during unpacking
|
optional- extensions that will be ignored during unpacking
|
||||||
|
--copy-meta-files
|
||||||
|
copy meta files alongside regular files
|
||||||
-h, --help Print help
|
-h, --help Print help
|
||||||
-V, --version Print version
|
-V, --version Print version
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::path::{PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Program for unpacking unitypackages files.
|
/// Program for unpacking unitypackages files.
|
||||||
#[derive(Parser, Debug, Clone)]
|
#[derive(Parser, Debug, Clone)]
|
||||||
|
|
@ -19,4 +19,8 @@ pub struct Args {
|
||||||
/// optional- extensions that will be ignored during unpacking
|
/// optional- extensions that will be ignored during unpacking
|
||||||
#[arg(long, action = clap::ArgAction::Append)]
|
#[arg(long, action = clap::ArgAction::Append)]
|
||||||
pub ignore_extensions: Option<Vec<String>>,
|
pub ignore_extensions: Option<Vec<String>>,
|
||||||
|
|
||||||
|
/// copy meta files alongside regular files
|
||||||
|
#[arg(long, default_value = "false", default_missing_value = "true")]
|
||||||
|
pub copy_meta_files: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ impl Unpacker {
|
||||||
pub fn process_data(&self) {
|
pub fn process_data(&self) {
|
||||||
let archive_path = Path::new(&self.args.input);
|
let archive_path = Path::new(&self.args.input);
|
||||||
let output_dir = Path::new(&self.args.output);
|
let output_dir = Path::new(&self.args.output);
|
||||||
|
let copy_meta_files = self.args.copy_meta_files;
|
||||||
let tmp_path = Path::new("./tmp_dir");
|
let tmp_path = Path::new("./tmp_dir");
|
||||||
if let Err(e) = Unpacker::extract_archive(archive_path, tmp_path) {
|
if let Err(e) = Unpacker::extract_archive(archive_path, tmp_path) {
|
||||||
println!("Failed to extract archive: {}", e);
|
println!("Failed to extract archive: {}", e);
|
||||||
|
|
@ -67,13 +68,20 @@ impl Unpacker {
|
||||||
let mapping: Vec<Asset> = receiver.iter().collect();
|
let mapping: Vec<Asset> = receiver.iter().collect();
|
||||||
let mapping_arc = Arc::new(mapping);
|
let mapping_arc = Arc::new(mapping);
|
||||||
|
|
||||||
mapping_arc.par_iter().for_each(|(asset)| {
|
mapping_arc.par_iter().for_each(|asset| {
|
||||||
let asset_hash = &asset.hash;
|
let asset_hash = &asset.hash;
|
||||||
let path = Path::new(&asset.path_name);
|
let path = Path::new(&asset.path_name);
|
||||||
let source_asset = Path::new(&*tmp_dir).join(asset_hash).join("asset");
|
let source_asset = Path::new(&*tmp_dir).join(asset_hash).join("asset");
|
||||||
let result_path = output_dir.join(path);
|
let result_path = output_dir.join(path);
|
||||||
|
|
||||||
process_directory(asset_hash, &asset.path_name, &result_path);
|
process_directory(asset_hash, &asset.path_name, &result_path);
|
||||||
|
if copy_meta_files && asset.has_meta {
|
||||||
|
let source_meta = Path::new(&*tmp_dir).join(asset_hash).join("asset.meta");
|
||||||
|
let mut meta_path = asset.path_name.clone();
|
||||||
|
meta_path.push_str(".meta");
|
||||||
|
let result_path = output_dir.join(meta_path);
|
||||||
|
fs::rename(source_meta, result_path).unwrap();
|
||||||
|
}
|
||||||
check_source_asset_exists(&source_asset);
|
check_source_asset_exists(&source_asset);
|
||||||
|
|
||||||
if self.args.fbx_to_gltf.is_some() {
|
if self.args.fbx_to_gltf.is_some() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue