From 84699a650c8042e3995a9576518749ad328c612f Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 9 Sep 2019 00:58:55 +0800 Subject: [PATCH] neogeo: support per-folder romsets.xml for children subfolders. --- file_io.cpp | 4 ++-- support/neogeo/loader.cpp | 16 ++++++++++++---- support/neogeo/loader.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index 090c79d..133aec4 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -937,8 +937,6 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons if (mode == SCANF_INIT) { file_name[0] = 0; - if (options & SCANO_NEOGEO) neogeo_scan_xml(); - if ((options & SCANO_NOENTER) || !isPathDirectory(path)) { char *p = strrchr(path, '/'); @@ -960,6 +958,8 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons file_name[0] = 0; } + if (options & SCANO_NEOGEO) neogeo_scan_xml(path); + sprintf(full_path, "%s/%s", getRootDir(), path); int path_len = strlen(full_path); diff --git a/support/neogeo/loader.cpp b/support/neogeo/loader.cpp index 0d0a460..493c4b2 100644 --- a/support/neogeo/loader.cpp +++ b/support/neogeo/loader.cpp @@ -548,10 +548,12 @@ static void parse_xml(const char* filename, const SAX_Callbacks* sax, void* user } } -int neogeo_scan_xml() +int neogeo_scan_xml(char *path) { static char full_path[1024]; - sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir); + sprintf(full_path, "%s/romsets.xml", path); + if(!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir); + SAX_Callbacks sax; SAX_Callbacks_init(&sax); @@ -980,8 +982,14 @@ int neogeo_romset_tx(char* name) if (!(system_type & 2)) { sprintf(full_path, "%s/%s/romset.xml", getRootDir(), name); - if (!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir); - + if (!FileExists(full_path)) + { + strcpy(full_path, name); + char *p = strrchr(full_path, '/'); + if (p) *p = 0; + strcat(full_path, "/romsets.xml"); + if (!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir); + } printf("xml for %s: %s\n", name, full_path); SAX_Callbacks sax; diff --git a/support/neogeo/loader.h b/support/neogeo/loader.h index 2bc794c..36b4fa0 100644 --- a/support/neogeo/loader.h +++ b/support/neogeo/loader.h @@ -6,5 +6,5 @@ #define NEO_FILE_SPR 3 int neogeo_romset_tx(char* name); -int neogeo_scan_xml(); +int neogeo_scan_xml(char *path); char *neogeo_get_altname(char *path, direntext_t *de);