Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/test_report_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "rpf_probe", "text_tables", "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.
Expand Down
15 changes: 3 additions & 12 deletions tools/text_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from file_mode import published_mode # noqa: E402
from hashdict import joaat # noqa: E402
from psin_dialogue import speaker_rows # noqa: E402
from report_paths import same_report_path # noqa: E402

RESOURCE_MAGIC = b"0DRP"
RPF9_MAGIC = b"9FPR"
Expand Down Expand Up @@ -284,7 +285,6 @@ def input_under(source: str, address: str):
return gamedata_index.carved_stream(address, source)
if not os.path.isfile(address): # a new file is written after the scan, so it was never read
return None
from report_paths import same_report_path
for root, _dirs, names in os.walk(source): # an unlistable folder fails the scan before anything is written
for name in names:
if same_report_path(address, os.path.join(root, name)):
Expand Down Expand Up @@ -463,15 +463,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")
Expand All @@ -487,7 +478,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))
Expand All @@ -501,7 +492,7 @@ def main(argv=None) -> int:
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}")
if os.path.isdir(source):
for flag, path in out_flags:
Expand Down