Skip to content

Commit 22a7759

Browse files
authored
menu: Add core picker directory fallback (MiSTer-devel#1202)
1 parent 830375c commit 22a7759

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

menu.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,20 @@ void StoreIdx_S(int idx, const char *path)
351351

352352
static char selPath[1024] = {};
353353

354+
static void ResolveExistingCorePath(char *path)
355+
{
356+
while (path[0] && !FileExists(path) && !PathIsDir(path))
357+
{
358+
char *p = strrchr(path, '/');
359+
if (!p)
360+
{
361+
path[0] = 0;
362+
break;
363+
}
364+
*p = 0;
365+
}
366+
}
367+
354368
static int changeDir(char *dir)
355369
{
356370
char curdir[128];
@@ -416,6 +430,7 @@ void SelectFile(const char* path, const char* pFileExt, int Options, unsigned ch
416430
if(strlen(selPath)) strcat(selPath, "/");
417431
strcat(selPath, get_rbf_name());
418432
}
433+
ResolveExistingCorePath(selPath);
419434
pFileExt = "RBFMRAMGL";
420435
home_dir = NULL;
421436
}

0 commit comments

Comments
 (0)