Files
romm/backend/handler/cloud_sync_emulator_names.py
Georges-Antoine Assi d5d9196db3 refactor(cloud-sync): apply simplify pass
- Hoist the file MD5 onto FSHandler; drop the blob handler copy
- Share path splitting, slot recency, cached MD5 and ROM visibility helpers
- Remove dead code (get_state_by_path, RomFile.file_ids, unused params)
- Scope WebDAV rom listing to one query; look up a single platform by slug
- Query saves once per manifest and batch ROM name resolution
- Read only the requested PSP bundle member; hash bundles from memory
- Single separator-safe lexical check in validate_path; same joined-path
  validation in write_file_streamed
- Stop stripping + on ROM rename, the download path encodes it (#2746)
- Trim comments to the repo's comment rules

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:55:32 -04:00

85 lines
2.5 KiB
Python

"""Maps RomM's `emulator` values (lowercase libretro core ids, e.g. "snes9x") to
RetroArch's save/state folder names (e.g. "Snes9x") and back.
RomM's web player matches saves on the core id, while RetroArch looks for the
exact folder name. The table follows github.com/Covin90/romm-retroarch-sync.
"""
RETROARCH_DIR_BY_ROMM_EMULATOR: dict[str, str] = {
# SNES
"snes9x": "Snes9x",
"bsnes": "bsnes",
"mesen-s": "Mesen-S",
# NES
"nestopia": "Nestopia",
"fceumm": "FCEUmm",
"mesen": "Mesen",
# PlayStation
"beetle_psx": "Beetle PSX",
"beetle_psx_hw": "Beetle PSX HW",
"pcsx_rearmed": "PCSX-ReARMed",
"swanstation": "SwanStation",
"mednafen_psx": "Beetle PSX",
"mednafen_psx_hw": "Beetle PSX HW",
# Game Boy
"gambatte": "Gambatte",
"sameboy": "SameBoy",
"tgbdual": "TGB Dual",
"mgba": "mGBA",
"vba_next": "VBA Next",
"vbam": "VBA-M",
# Genesis / Mega Drive
"genesis_plus_gx": "Genesis Plus GX",
"blastem": "BlastEm",
"picodrive": "PicoDrive",
# Nintendo 64
"mupen64plus_next": "Mupen64Plus-Next",
"parallel_n64": "ParaLLEl N64",
# Saturn
"beetle_saturn": "Beetle Saturn",
"kronos": "Kronos",
"mednafen_saturn": "Beetle Saturn",
# Arcade / Neo Geo
"mame": "MAME",
"fbneo": "FBNeo",
"fbalpha": "FB Alpha",
# PlayStation 2 / GameCube
"pcsx2": "PCSX2",
"play": "Play!",
"dolphin": "Dolphin",
# Dreamcast
"flycast": "Flycast",
"redream": "Redream",
# Atari
"stella": "Stella",
# PC Engine
"beetle_pce": "Beetle PCE",
"beetle_pce_fast": "Beetle PCE Fast",
"mednafen_pce": "Beetle PCE",
"mednafen_pce_fast": "Beetle PCE Fast",
# Other common cores
"dosbox_pure": "DOSBox-Pure",
"scummvm": "ScummVM",
"ppsspp": "PPSSPP",
"desmume": "DeSmuME",
"melonds": "melonDS",
"citra": "Citra",
}
# Reversed so the first core listed for a shared folder (e.g. "Beetle PSX") wins.
ROMM_EMULATOR_BY_RETROARCH_DIR: dict[str, str] = {
dir_name: emulator
for emulator, dir_name in reversed(RETROARCH_DIR_BY_ROMM_EMULATOR.items())
}
def to_romm_emulator(retroarch_dir_name: str) -> str:
"""RomM's `emulator` for a RetroArch folder name, kept verbatim when unknown."""
return ROMM_EMULATOR_BY_RETROARCH_DIR.get(retroarch_dir_name, retroarch_dir_name)
def to_retroarch_dir_name(romm_emulator: str) -> str:
"""RetroArch's folder name for a RomM `emulator`, unchanged when unknown."""
return RETROARCH_DIR_BY_ROMM_EMULATOR.get(romm_emulator, romm_emulator)