feat: settle launcher names the code fills

A search a launcher stops at the first held name of is filled, and a
copy from the platform's own package or script brings its own file:
neither is a name the collection lacks. A launcher that writes its
file into the setting a profile entry is read from (config_key) now
receives that entry's held file under its own name, in the report and
in the pack.
This commit is contained in:
Abdessamad Derraz committed 2026-11-09 17:31:18 +01:00
1 parent 9bb1cfaa82
commit 979111f6f2
4 files changed
+95 -3

No files matched your search

+26 -1
View File
@@ -50,7 +50,8 @@ from common import (
select_emulator_profiles,
)
from hashing import parse_hash_list
from launchers import LauncherLayer, declared_destinations, held_record
from launchers import LauncherLayer, declared_destinations, held_record, set_by
from launchers import _directories as launcher_directories
from launchers import _names as launcher_names
from validation import (
case_folded_slots,
@@ -1151,6 +1152,16 @@ def launcher_reads_not_held(
a copy is reported with `held_as`, since the launcher does not open it
under the name it asks for. *emulator* keeps the records whose emulator
name designates that profile.
Three records ask for nothing the collection lacks. A search keeps the
first name it finds, so one held name fills it: RetroBat's Amiberry
launcher returns the first of kick34005.A500, kick34005.A500.rom and
amiga-os-130.rom that exists (Amiberry.Generator.cs:674-699). A copy
whose source lies outside the BIOS directory brings a file the platform
installs itself, from its own package or written by its own script
(RetroPie's lr-vecx copies $md_inst/system.bin). A file handed to the
setting a reader's profile entry is read from is that entry's file,
which the pack places under the launcher's name.
"""
holder = _NameHolder(db, profiles, data_dir_registry)
every_profile = set(profiles)
@@ -1169,6 +1180,20 @@ def launcher_reads_not_held(
if emulator and emulator not in readers:
continue
folds = bool(record.get("case_insensitive") or config.get("case_insensitive_fs"))
base = str(config.get("base_destination") or "bios")
if record.get("kind") == "copies" and not launcher_directories(record, base):
continue
passes_to = str(record.get("passes_to") or "")
if passes_to and any(
set_by(entry, passes_to) and holder._entry_held(entry)
for key in readers
for entry in profiles[key].get("files") or []
):
continue
if record.get("kind") == "names_searched" and any(
(found := holder.held(name)) and (found[1] or folds) for name in names
):
continue
reader = {
"emulator": str(record.get("emulator", "")),
"build": str(record.get("build", "")),
+24
View File
@@ -65,6 +65,7 @@ class LauncherPlace:
anchored: bool
conditional: bool
source_ref: str
passes_to: str = ""
def fold(self, name: str) -> str:
return name.lower() if self.case_insensitive else name
@@ -87,6 +88,24 @@ class LauncherPlace:
)
def setting_tokens(passes_to: str) -> set[str]:
"""The words of a record's ``passes_to``, as an emulator setting is spelled.
"command line -romfile4p" hands the file to sdltrs's romfile4p option,
"settings.bml NeoGeoPocket/Firmware/BIOS.World" to an ares setting.
"""
return {
word.strip("()\"',;").lstrip("-")
for word in passes_to.split()
} - {""}
def set_by(entry: dict, passes_to: str) -> bool:
"""Whether a launcher hands its file to the setting a profile entry is read from."""
key = str(entry.get("config_key") or "")
return bool(key) and key in setting_tokens(passes_to)
def _bios_relative(directory: str, base: str) -> str | None:
"""A launcher directory relative to the BIOS root, None when it is not one."""
directory = directory.strip().rstrip("/")
@@ -189,6 +208,7 @@ def launcher_places(config: dict) -> list[LauncherPlace]:
"anchored": anchored,
"conditional": bool(record.get("depends_on_option")),
"source_ref": str(record.get("source_ref", "")),
"passes_to": str(record.get("passes_to") or ""),
}
if kind == "names_searched":
# Each directory in turn, every name in it.
@@ -461,6 +481,10 @@ class LauncherLayer:
names = own & basenames
if names:
return _Candidate(entry, names, False)
# RetroPie runs sdl2trs with -romfile4p $biosdir/level4p.rom: the
# file under that name is the one the romfile4p slot reads.
if set_by(entry, place.passes_to):
return _Candidate(entry, basenames, False)
content = {
place.fold(path.rsplit("/", 1)[-1])
for path in place.paths