Move platform-specific ROM path adding code into plat modules

This commit is contained in:
Cacodemon345
2022-04-06 16:16:25 +06:00
parent 2c63f5b497
commit 1a3a7bec0e
6 changed files with 145 additions and 49 deletions

View File

@@ -45,6 +45,8 @@
#include <86box/timer.h>
#include <86box/nvr.h>
#include <86box/video.h>
#include <86box/mem.h>
#include <86box/rom.h>
#define GLOBAL
#include <86box/plat.h>
#include <86box/ui.h>
@@ -910,6 +912,30 @@ plat_mmap(size_t size, uint8_t executable)
}
void
plat_init_rom_paths()
{
wchar_t appdata_dir[1024] = { L'\0' };
if (_wgetenv("LOCALAPPDATA") && _wgetenv("LOCALAPPDATA")[0] != L'\0') {
char appdata_dir_a[1024] = { '\0' };
size_t len = 0;
wcsncpy(appdata_dir, _wgetenv("LOCALAPPDATA"), 1024);
len = wcslen(appdata_dir);
if (appdata_dir[len - 1] != L'\\') {
appdata_dir[len] = L'\\';
appdata_dir[len + 1] = L'\0';
}
wcscat(appdata_dir, "86box");
CreateDirectoryW(appdata_dir, NULL);
wcscat(appdata_dir, "\\roms");
CreateDirectoryW(appdata_dir, NULL);
wcscat(appdata_dir, "\\");
c16stombs(appdata_dir_a, appdata_dir, 1024);
add_rom_path(appdata_dir_a);
}
}
void
plat_munmap(void *ptr, size_t size)
{