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", "odrp_7a", "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.
Expand Down
16 changes: 4 additions & 12 deletions tools/odrp_7a.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from file_mode import published_mode # noqa: E402
from report_paths import same_report_path # noqa: E402

SIGNATURE = b"0DRP"
VERSION = 0x7A
Expand Down Expand Up @@ -1179,15 +1180,6 @@ def _positive_bytes_arg(text):
return value


def _same_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 _is_rpf_file(path):
if not os.path.isfile(path) or os.path.getsize(path) < 4:
return path.lower().endswith(".rpf")
Expand Down Expand Up @@ -1218,19 +1210,19 @@ def main(argv=None):
parent = os.path.dirname(os.path.abspath(args.out))
if not os.path.isdir(parent):
ap.error(f"{parent} is not a folder, so {args.out} cannot be written")
if _same_path(args.source, args.out):
if same_report_path(args.source, args.out):
ap.error("output must not overwrite the source")

if os.path.isdir(args.source):
if args.start is not None or args.limit is not None:
ap.error("--start and --limit apply to an .rpf archive, not a directory")
manifest = os.path.join(args.source, "index.json")
if os.path.isfile(manifest) and _same_path(manifest, args.out):
if os.path.isfile(manifest) and same_report_path(manifest, args.out):
ap.error(f"output would overwrite the carve manifest: {args.out}")
if os.path.isfile(args.out):
for name in os.listdir(args.source):
cand = os.path.join(args.source, name)
if _is_carved_file(cand) and _same_path(cand, args.out):
if _is_carved_file(cand) and same_report_path(cand, args.out):
ap.error(f"output would overwrite an input file: {args.out}")
elif os.path.isfile(args.source):
is_rpf = _is_rpf_file(args.source)
Expand Down
Loading