From 9ef642c5e35c75c0dbe6b6b1d7dea5116abad57e Mon Sep 17 00:00:00 2001 From: sindoring Date: Tue, 24 Mar 2026 09:40:32 +0400 Subject: [PATCH] =?UTF-8?q?MPQ=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=B1=D1=8B=D1=82=D1=8C=20=D0=BA=D0=B0=D0=BF=D1=81=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/src/main.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tool/src/main.rs b/tool/src/main.rs index 59b17dd..4b5e57b 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -3,30 +3,31 @@ use std::error::Error; use std::path::PathBuf; use walkdir::WalkDir; -use wow_mpq::{ArchiveBuilder, FormatVersion, ListfileOption}; use wow_mpq::compression::flags; +use wow_mpq::{ArchiveBuilder, FormatVersion, ListfileOption}; fn main() -> Result<(), Box> { // Read arguments let args: Vec = env::args().collect(); if args.len() != 3 { - eprintln!("Usage: mpq-builder "); + eprintln!("Usage: mpq-builder "); std::process::exit(1); } let input_dir = PathBuf::from(&args[1]); - let output_file = &args[2]; + let mut output_file = PathBuf::from(&args[2]); + output_file.set_extension("MPQ"); if !input_dir.exists() { return Err("Input directory does not exist".into()); } - // Normalize base path (IMPORTANT for Windows) + // Normalize base path (important for Windows) let base = input_dir.canonicalize()?; println!("Input directory: {}", base.display()); - println!("Output file: {}", output_file); + println!("Output file: {}", output_file.display()); // Configure MPQ builder let mut builder = ArchiveBuilder::new() @@ -41,7 +42,7 @@ fn main() -> Result<(), Box> { .filter_map(|e| e.ok()) .filter(|e| e.file_type().is_file()) { - // Canonicalize each file path (fixes StripPrefixError) + // Canonicalize each file path to avoid StripPrefixError. let full_path = entry.path().canonicalize()?; // Safely compute relative path @@ -53,10 +54,8 @@ fn main() -> Result<(), Box> { } }; - // Convert to MPQ-style path (forward slashes!) - let archive_path = rel_path - .to_string_lossy() - .replace("\\", "/"); + // Convert to MPQ-style path (forward slashes) + let archive_path = rel_path.to_string_lossy().replace("\\", "/"); println!("Adding: {}", archive_path); @@ -64,9 +63,9 @@ fn main() -> Result<(), Box> { } // Build archive - builder.build(output_file)?; + builder.build(&output_file)?; - println!("✅ MPQ archive created: {}", output_file); + println!("MPQ archive created: {}", output_file.display()); Ok(()) -} \ No newline at end of file +}