Skip nonexistent paths and disable text replacement

This commit is contained in:
Jáchym Toušek
2022-07-14 18:04:34 +02:00
parent f006bfcbef
commit c136409116

View File

@@ -66,6 +66,7 @@ fn main() {
assert_eq!(unity, &version.trim()); assert_eq!(unity, &version.trim());
// 1. texts // 1. texts
if arc_number.clone() < 9 {
let status = Command::new("python") let status = Command::new("python")
.env("PYTHONIOENCODING", "utf-8") .env("PYTHONIOENCODING", "utf-8")
.arg("scripts/UnityTextModifier.py") .arg("scripts/UnityTextModifier.py")
@@ -76,15 +77,14 @@ fn main() {
.expect("failed to execute UnityTextModifier.py"); .expect("failed to execute UnityTextModifier.py");
assert!(status.success()); assert!(status.success());
}
// 2. images // 2. images
copy_images("assets/images/shared", &directory_assets); copy_images("assets/images/shared", &directory_assets);
copy_images(format!("assets/images/{}", &arc_type).as_ref(), &directory_assets); copy_images(format!("assets/images/{}", &arc_type).as_ref(), &directory_assets);
copy_images(format!("assets/images/specific/{}", &chapter).as_ref(), &directory_assets); copy_images(format!("assets/images/specific/{}", &chapter).as_ref(), &directory_assets);
let version_specific_path = format!("assets/images/version-specific/{}-{}", &chapter, &unity); let version_specific_path = format!("assets/images/version-specific/{}-{}", &chapter, &unity);
if Path::new(&version_specific_path).exists() {
copy_images(version_specific_path.as_ref(), &directory_assets); copy_images(version_specific_path.as_ref(), &directory_assets);
}
if arc_number.clone() == 9 { if arc_number.clone() == 9 {
fs::rename("output/assets/configbg_Texture2D.png", "output/assets/56configbg_Texture2D.png").expect("Unable to rename"); fs::rename("output/assets/configbg_Texture2D.png", "output/assets/56configbg_Texture2D.png").expect("Unable to rename");
} else if arc_number.clone() == 8 { } else if arc_number.clone() == 8 {
@@ -202,6 +202,10 @@ fn main() {
} }
fn copy_images(from: &str, to: &str) { fn copy_images(from: &str, to: &str) {
if ! Path::new(&from).exists() {
println!("Path {} not found", from);
return
}
println!("Copying files from {}", from); println!("Copying files from {}", from);
for entry in fs::read_dir(from).expect("Can't read directory") { for entry in fs::read_dir(from).expect("Can't read directory") {
let path = entry.unwrap().path(); let path = entry.unwrap().path();
@@ -210,6 +214,10 @@ fn copy_images(from: &str, to: &str) {
} }
fn copy_files(from: &str, to: &str) { fn copy_files(from: &str, to: &str) {
if ! Path::new(&from).exists() {
println!("Path {} not found", from);
return
}
println!("Copying files from {}", from); println!("Copying files from {}", from);
for entry in fs::read_dir(from).expect("Can't read directory") { for entry in fs::read_dir(from).expect("Can't read directory") {
let path = entry.unwrap().path(); let path = entry.unwrap().path();