From 0d6800ad026387ac6c5b3034598d39bb4365719c Mon Sep 17 00:00:00 2001 From: Enea Cortese <148778899+breachato@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:36:58 +0100 Subject: [PATCH] text_tables: ask report_paths for the report-path guard --- tools/text_tables.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/text_tables.py b/tools/text_tables.py index 7b2fc283b1..40842112ed 100644 --- a/tools/text_tables.py +++ b/tools/text_tables.py @@ -59,6 +59,7 @@ sys.path.insert(0, ROOT) from file_mode import published_mode # noqa: E402 from hashdict import joaat # noqa: E402 +from report_paths import same_report_path # noqa: E402 RESOURCE_MAGIC = b"0DRP" RPF9_MAGIC = b"9FPR" @@ -425,15 +426,6 @@ def _write_csv(path, fields, rows): return n -def _same_output_path(first: str, second: str) -> bool: - if os.path.normcase(os.path.realpath(first)) == os.path.normcase(os.path.realpath(second)): - return True - try: - return os.path.samefile(first, second) - except OSError: - return False - - def main(argv=None) -> int: ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument("sources", nargs="+", help="rpf9_carve.py directory, .rpf archive, or resource files/dirs") @@ -447,7 +439,7 @@ def main(argv=None) -> int: outs = [path for _, path in out_flags] seen = [] for flag, p in out_flags: - if any(_same_output_path(p, prev) for prev in seen): + if any(same_report_path(p, prev) for prev in seen): ap.error("outputs must be distinct files") seen.append(p) parent = os.path.dirname(os.path.abspath(p)) @@ -457,11 +449,11 @@ def main(argv=None) -> int: if not os.path.exists(path): print(f"text_tables: error: {path}: no such file or directory", file=sys.stderr) return 2 - if any(os.path.exists(o) and os.path.samefile(path, o) for o in outs): + if any(same_report_path(path, o) for o in outs): ap.error("an output must not overwrite an input") for source in a.sources: index = os.path.join(source, "index.json") - if os.path.isdir(source) and os.path.isfile(index) and any(_same_output_path(index, o) for o in outs): + if os.path.isdir(source) and os.path.isfile(index) and any(same_report_path(index, o) for o in outs): ap.error(f"an output must not overwrite an input: {index}") scan = Scan()