Remove pathdiff dependency and unused function
This commit is contained in:
parent
1d7e43fa5c
commit
6a19b0fbb0
|
|
@ -23,7 +23,6 @@ opt-level = 2
|
|||
clap = { version = "4.4", features = ["derive"] }
|
||||
flate2 = "1.0"
|
||||
gltf = "1.4.0"
|
||||
pathdiff = "0.2.1"
|
||||
rayon = "1.8.0"
|
||||
regex = "1.10.2"
|
||||
tar = "0.4"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rayon::prelude::*;
|
|||
use std::borrow::Cow;
|
||||
|
||||
use std::fs::File;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -18,10 +18,6 @@ pub struct Unpacker {
|
|||
pub assets: Vec<Asset>,
|
||||
}
|
||||
|
||||
fn get_relative_path(path1: &Path, path2: &Path) -> Option<PathBuf> {
|
||||
pathdiff::diff_paths(path1, path2)
|
||||
}
|
||||
|
||||
impl Unpacker {
|
||||
pub fn prepare_environment(&self) {
|
||||
let archive_path = Path::new(&self.args.input);
|
||||
|
|
@ -135,19 +131,22 @@ impl Unpacker {
|
|||
let reader = io::BufReader::new(file);
|
||||
let mut gltf = gltf::Gltf::from_reader(reader).unwrap();
|
||||
let mut json = gltf.document.into_json();
|
||||
if let Some(rel_path) = get_relative_path(texture_asset, gltf_path) {
|
||||
for image in json.images.iter_mut() {
|
||||
let result = rel_path.file_name().unwrap().to_str().unwrap().to_string();
|
||||
let required_file = gltf_path.with_file_name(&result);
|
||||
if !required_file.exists() {
|
||||
fs::copy(texture_asset, gltf_path.with_file_name(&result)).unwrap();
|
||||
}
|
||||
println!(
|
||||
"Image{:?}: {:?} to be replaced with: {}",
|
||||
image.name, image.uri, &result
|
||||
);
|
||||
image.uri = Some(result);
|
||||
for image in json.images.iter_mut() {
|
||||
let result = texture_asset.file_name().unwrap().to_str().unwrap().to_string();
|
||||
let required_file = gltf_path.with_file_name(&result);
|
||||
if !required_file.exists() {
|
||||
fs::copy(texture_asset, gltf_path.with_file_name(&result)).unwrap();
|
||||
}
|
||||
if let Some(old_path) = &image.uri {
|
||||
if old_path.eq(&result){
|
||||
return;
|
||||
}
|
||||
}
|
||||
println!(
|
||||
"Image{:?}: {:?} to be replaced with: {}",
|
||||
image.name, image.uri, &result
|
||||
);
|
||||
image.uri = Some(result);
|
||||
}
|
||||
|
||||
gltf.document = Document::from_json(json.clone()).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue