feat(editor): add --rename-by-magic extension recovery flag

Reads the 4-byte magic of a file, looks it up in the shared
format table, and renames the file to use the correct .w*
extension. Useful when files have lost their extensions
(downloaded as 'data.bin', extracted from a tarball with
mangled metadata, or copied via a tool that strips suffixes).

Safe by default — refuses to overwrite an existing target;
pass --force to allow overwrite. --dry-run prints the planned
move without touching the filesystem. Files that already have
the correct extension are a no-op. Unrecognized magic exits
1 with the bytes printed for diagnostic context.

Reuses cli_format_table.cpp so any future format addition is
picked up automatically.
This commit is contained in:
Kelsi 2026-05-09 19:29:18 -07:00
parent 824a6c8cab
commit 4b928274b8
6 changed files with 118 additions and 1 deletions

View file

@ -1353,6 +1353,8 @@ void printUsage(const char* argv0) {
std::printf(" Auto-detect any .w* file by 4-byte magic; report format / version / catalog name / entry count + suggest --info-* flag\n");
std::printf(" --summary-dir <dir> [--json]\n");
std::printf(" Recursively walk a directory; report per-format file count, total entries, and bytes for every Wowee open format found\n");
std::printf(" --rename-by-magic <file> [--dry-run] [--force]\n");
std::printf(" Recover the correct .w* extension on a file by reading its 4-byte magic. --dry-run prints the planned move; --force overwrites\n");
std::printf(" --gen-animations <wani-base> [name]\n");
std::printf(" Emit .wani starter: 5 essential animations (Stand / Walk / Run / Death / AttackUnarmed) with fallback chains\n");
std::printf(" --gen-animations-combat <wani-base> [name]\n");