MPQ должен быть капсом
This commit is contained in:
+11
-12
@@ -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<dyn Error>> {
|
||||
// Read arguments
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() != 3 {
|
||||
eprintln!("Usage: mpq-builder <input_dir> <output.mpq>");
|
||||
eprintln!("Usage: mpq-builder <input_dir> <output.MPQ>");
|
||||
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<dyn Error>> {
|
||||
.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<dyn Error>> {
|
||||
}
|
||||
};
|
||||
|
||||
// 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<dyn Error>> {
|
||||
}
|
||||
|
||||
// Build archive
|
||||
builder.build(output_file)?;
|
||||
builder.build(&output_file)?;
|
||||
|
||||
println!("✅ MPQ archive created: {}", output_file);
|
||||
println!("MPQ archive created: {}", output_file.display());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user