From f5352e05584e793faf65905aca56bcfaef0c3cbb Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Tue, 2 Jun 2026 17:57:42 -0700 Subject: [PATCH] midiemu: build MT-32 ROM paths portably Use fixtrailing() when constructing the mt32-roms directory path instead of embedding a Windows directory separator. Keep the legacy C:\mt32-rom-data fallback on Windows only. Non-Windows hosts should not probe that path while checking Munt availability. --- midiemu.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/midiemu.cpp b/midiemu.cpp index a947b300..98ae5711 100644 --- a/midiemu.cpp +++ b/midiemu.cpp @@ -86,14 +86,23 @@ static bool load_rom(const TCHAR *path, const TCHAR *name) return err >= 0; } +static void set_mt32_rom_path(TCHAR *path) +{ + fetch_rompath(path, MAX_DPATH); + fixtrailing(path); + _tcscat(path, _T("mt32-roms")); + fixtrailing(path); +} + static void midi_emu_add_roms(void) { TCHAR path[MAX_DPATH]; - fetch_rompath(path, sizeof(path) / sizeof(TCHAR)); - _tcscat(path, _T("mt32-roms\\")); + set_mt32_rom_path(path); +#ifdef _WIN32 if (!my_existsdir(path)) { _tcscpy(path, _T("c:\\mt32-rom-data\\")); } +#endif if (!my_existsdir(path)) { write_log(_T("mt32emu: rom path missing\n")); return; @@ -138,10 +147,13 @@ bool midi_emu_available(const TCHAR *id) if (rc == 0) { fetch_rompath(path, sizeof(path) / sizeof(TCHAR)); } else if (rc == 1) { - fetch_rompath(path, sizeof(path) / sizeof(TCHAR)); - _tcscat(path, _T("mt32-roms\\")); + set_mt32_rom_path(path); } else if (rc == 2) { +#ifdef _WIN32 _tcscpy(path, _T("C:\\mt32-rom-data\\")); +#else + continue; +#endif } if (!my_existsdir(path)) { continue; -- 2.47.3