From b37cb502ba223856d59ef63c983a5c2c80c44cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= <13226155+dhrdlicka@users.noreply.github.com> Date: Thu, 21 Aug 2025 16:51:36 +0200 Subject: [PATCH] Implement default VMM directory --- src/config.c | 8 +++++--- src/include/86box/plat.h | 1 + src/qt/qt_platform.cpp | 14 ++++++++++++++ src/unix/unix.c | 8 ++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 9856afc3b..a76a08126 100644 --- a/src/config.c +++ b/src/config.c @@ -143,8 +143,7 @@ load_global(void) if (p != NULL) strncpy(vmm_path, p, sizeof(vmm_path) - 1); else - // [todo] plat_vmm_path() - vmm_path[0] = 0; + plat_get_vmm_dir(vmm_path, sizeof(vmm_path)); } /* Load "General" section. */ @@ -2215,7 +2214,10 @@ save_global(void) else ini_section_delete_var(cat, "vmm_disabled"); - ini_section_set_string(cat, "vmm_path", vmm_path); + if (vmm_path[0] != 0) + ini_section_set_string(cat, "vmm_path", vmm_path); + else + ini_section_delete_var(cat, "vmm_path"); } /* Save "General" section. */ diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index ef06b3429..db3c4c14b 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -146,6 +146,7 @@ extern void plat_get_exe_name(char *s, int size); extern void plat_get_global_config_dir(char *outbuf, size_t len); extern void plat_get_global_data_dir(char *outbuf, size_t len); extern void plat_get_temp_dir(char *outbuf, uint8_t len); +extern void plat_get_vmm_dir(char *outbuf, uint8_t len); extern void plat_init_rom_paths(void); extern int plat_dir_check(char *path); extern int plat_dir_create(char *path); diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index ee2e40d1d..74fe8249a 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -694,6 +694,20 @@ plat_get_temp_dir(char *outbuf, const uint8_t len) strncpy(outbuf, dir.canonicalPath().toUtf8().constData(), len); } +void +plat_get_vmm_dir(char *outbuf, const size_t len) +{ + const auto dir = QDir(QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0]).filePath("86Box VMs"); + + if (!dir.exists()) { + if (!dir.mkpath(".")) { + qWarning("Failed to create VMs directory %s", dir.absolutePath().toUtf8().constData()); + } + } + + strncpy(outbuf, dir.canonicalPath().toUtf8().constData(), len); +} + void plat_init_rom_paths(void) { diff --git a/src/unix/unix.c b/src/unix/unix.c index a28c4fc47..d35543548 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -901,6 +901,14 @@ plat_get_temp_dir(char *outbuf, uint8_t len) path_slash(outbuf); } +void +plat_get_vmm_dir(char *outbuf, const size_t len) +{ + // Return empty string. SDL 86Box does not have a VM manager + if (len > 0) + outbuf[0] = 0; +} + bool process_media_commands_3(uint8_t *id, char *fn, uint8_t *wp, int cmdargc) {