When '<dirname>/<dirname>.nro' is not found, use the first NRO found via dir-listing if there's only 1 NRO in the directory (only for paths starting with 'sdmc:/switch'). Closes #9. Added a comment and removed old code using StrId_Directory.
This commit is contained in:
parent
4ffb8e1355
commit
1730ed1889
@ -139,17 +139,45 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
|||||||
strcpy(me->name, name);
|
strcpy(me->name, name);
|
||||||
if (me->type == ENTRY_TYPE_FOLDER)
|
if (me->type == ENTRY_TYPE_FOLDER)
|
||||||
{
|
{
|
||||||
|
//Check for <dirpath>/<dirname>.nro
|
||||||
snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s/%.*s.nro", (int)sizeof(tempbuf)/2, me->path, (int)sizeof(tempbuf)/2-7, name);
|
snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s/%.*s.nro", (int)sizeof(tempbuf)/2, me->path, (int)sizeof(tempbuf)/2-7, name);
|
||||||
bool found = fileExists(tempbuf);
|
bool found = fileExists(tempbuf);
|
||||||
|
|
||||||
|
//Use the first .nro found in the directory, if there's only 1 NRO in the directory. Only used for paths which start with "sdmc:/switch".
|
||||||
|
if (!found && strncmp(me->path, "sdmc:/switch", 12)==0) {
|
||||||
|
DIR* dir;
|
||||||
|
struct dirent* dp;
|
||||||
|
u32 nro_count=0;
|
||||||
|
|
||||||
|
dir = opendir(me->path);
|
||||||
|
if (dir) {
|
||||||
|
while ((dp = readdir(dir))) {
|
||||||
|
if (dp->d_name[0]=='.')//Check this here so that it's consistent with menuScan().
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const char* ext = getExtension(dp->d_name);
|
||||||
|
if (strcasecmp(ext, ".nro")==0) {
|
||||||
|
nro_count++;
|
||||||
|
if (nro_count>1) {
|
||||||
|
found = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s/%.*s", (int)sizeof(tempbuf)/2, me->path, (int)sizeof(tempbuf)/2-7, dp->d_name);
|
||||||
|
found = fileExists(tempbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
//isOldAppFolder = true;
|
//isOldAppFolder = true;
|
||||||
shortcut = false;
|
shortcut = false;
|
||||||
me->type = ENTRY_TYPE_FILE;
|
me->type = ENTRY_TYPE_FILE;
|
||||||
strcpy(me->path, tempbuf);
|
strcpy(me->path, tempbuf);
|
||||||
} /*else
|
}
|
||||||
strcpy(me->name, textGetString(StrId_Directory));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me->type == ENTRY_TYPE_FILE)
|
if (me->type == ENTRY_TYPE_FILE)
|
||||||
|
Loading…
Reference in New Issue
Block a user