From 0fd3042e0cf18ed58657062ce2c1925e6bafdcec Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 7 Apr 2022 00:57:16 +0600 Subject: [PATCH] qt: Add support for loading ROMs from ~/Documents/86Box/roms on macOS --- src/qt/qt_platform.cpp | 5 ++++- src/unix/unix.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index c48a84020..5f4d23baa 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -589,7 +589,10 @@ plat_chdir(char *path) void plat_init_rom_paths() { -#if !defined __APPLE__ && !defined _WIN32 +#if defined __APPLE__ + QDir::root().mkpath(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath())); + add_rom_path(QStringLiteral("%1/Documents/86Box/roms/").arg(QDir::homePath()).toUtf8().constData()); +#elif !defined _WIN32 if (getenv("XDG_DATA_HOME")) { char xdg_rom_path[1024] = { 0 }; strncpy(xdg_rom_path, getenv("XDG_DATA_HOME"), 1024); diff --git a/src/unix/unix.c b/src/unix/unix.c index 1c8917626..5f6429b89 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -796,6 +796,13 @@ plat_init_rom_paths() add_rom_path("/usr/local/share/86Box/roms/"); add_rom_path("/usr/share/86Box/roms/"); } +#else + char home_rom_path[1024] = { '\0' }; + snprintf(home_rom_path, 1024, "%s/Documents/86Box/", getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir); + plat_dir_create(home_rom_path); + strcat(home_rom_path, "roms/"); + plat_dir_create(home_rom_path); + add_rom_path(home_rom_path); #endif }