feat(clew): extract rpa archives into game tree

This commit is contained in:
2026-09-07 15:34:26 -04:00
parent a96d3cdd16
commit a417a51e6b

View File

@@ -8,6 +8,8 @@ import sys
from collections import deque
from pathlib import Path
from rpycdec.rpa import extract_rpa
LOG = logging.getLogger(__name__)
def parse_args(argv: list[str]) -> argparse.Namespace:
@@ -32,11 +34,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
action="store_true",
help="Replace Clew-managed output directories.",
)
parser.add_argument(
"--suffix",
action="append",
help="Extract only archive paths with this suffix. Repeatable.",
)
return parser.parse_args(argv)
@@ -57,6 +54,12 @@ def get_output_directory(output_root: Path, folder: str) -> Path:
return directory
def extract_archive(archive: Path, destination: Path) -> None:
destination.mkdir(parents=True, exist_ok=True)
with archive.open("rb") as handle:
extract_rpa(handle, output_dir=str(destination))
def extract_game_files(game_root: Path, output_path: Path) -> None:
queue = deque(game_root.iterdir())
@@ -67,6 +70,8 @@ def extract_game_files(game_root: Path, output_path: Path) -> None:
if item.is_dir():
destination.mkdir(parents=True, exist_ok=True)
queue.extend(item.iterdir())
elif item.is_file() and item.suffix.lower() == ".rpa":
extract_archive(item, destination.with_suffix(""))
elif item.is_file():
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(item, destination)