diff --git a/tests/test_report_paths.py b/tests/test_report_paths.py index 5a22fe2cc5..fd78d31585 100644 --- a/tests/test_report_paths.py +++ b/tests/test_report_paths.py @@ -22,7 +22,7 @@ # Tools that use report_paths and must not define their own copy again. SHARED = ("anim_index", "awc_manifest", "bink_index", "gamedata_index", "gamedata_xml", "gen_d3d12_stubs", - "glb_inspect", "meshlet_page", "navmesh_index", "rpf_probe", "tile_probe", "world_index", + "glb_inspect", "meshlet_page", "navmesh_index", "rbf0_tree", "rpf_probe", "tile_probe", "world_index", "world_lights_paths", "world_names") # The one tool that still carries its own copy (an open pull request edits its call site). Do not add to this list: # import report_paths instead. diff --git a/tools/rbf0_tree.py b/tools/rbf0_tree.py index 0a69d5db4a..a0361cf5b7 100644 --- a/tools/rbf0_tree.py +++ b/tools/rbf0_tree.py @@ -31,6 +31,7 @@ import rbf0_index # noqa: E402 from file_mode import published_mode # noqa: E402 +from report_paths import same_report_path # noqa: E402 MAGIC = rbf0_index.MAGIC PROLOGUE = rbf0_index.PROLOGUE @@ -677,15 +678,6 @@ def write_json(path, docs, summary): raise -def same_output_path(first, second): - 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): ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument("source", help="a carve directory, a complete resource, or a single RBF0 stream") @@ -699,11 +691,11 @@ def main(argv=None): args = ap.parse_args(argv) # The reports are written after the decode: an out or --csv naming the source used to replace it, and the # same file for both left only the CSV. - if args.csv and same_output_path(args.out, args.csv): + if args.csv and same_report_path(args.out, args.csv): ap.error("out and --csv must be different files") if os.path.isfile(args.source): for flag, path in (("out", args.out), ("--csv", args.csv)): - if path and same_output_path(path, args.source): + if path and same_report_path(path, args.source): ap.error(f"{flag} would overwrite the source {args.source}") elif os.path.isdir(args.source): # A carve folder: out or --csv naming one of its streams used to replace that stream, and --xml on the @@ -714,9 +706,9 @@ def main(argv=None): except OSError: streams = [] # decode_source reports the unreadable folder for flag, path in (("out", args.out), ("--csv", args.csv)): - if path and os.path.exists(path) and any(same_output_path(path, s) for s in streams): + if path and os.path.exists(path) and any(same_report_path(path, s) for s in streams): ap.error(f"{flag} would overwrite the stream {path} in the source folder") - if args.xml and same_output_path(args.xml, args.source): + if args.xml and same_report_path(args.xml, args.source): ap.error("--xml must not be the source folder: its XML files would be read as streams") def progress(n, total):