Added support for loading {filename}.nacp similar to {filename}.jpg, when processing files for fileassoc.
This commit is contained in:
parent
9e257d7606
commit
f0ef77b2f2
@ -168,6 +168,26 @@ static bool menuEntryLoadEmbeddedNacp(menuEntry_s* me) {
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool menuEntryLoadExternalNacp(menuEntry_s* me, const char* path) {
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if(stat(path, &st)==-1) return false;
|
||||||
|
|
||||||
|
FILE* f = fopen(path, "rb");
|
||||||
|
if (!f) return false;
|
||||||
|
|
||||||
|
me->nacp = (NacpStruct*)malloc(sizeof(NacpStruct));
|
||||||
|
if (me->nacp == NULL) {
|
||||||
|
fclose(f);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
memset(me->nacp, 0, sizeof(NacpStruct));
|
||||||
|
|
||||||
|
bool ok = fread(me->nacp, sizeof(NacpStruct), 1, f) == 1;
|
||||||
|
fclose(f);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
/*static void fixSpaceNewLine(char* buf) {
|
/*static void fixSpaceNewLine(char* buf) {
|
||||||
char *outp = buf, *inp = buf;
|
char *outp = buf, *inp = buf;
|
||||||
char lastc = 0;
|
char lastc = 0;
|
||||||
@ -438,11 +458,23 @@ bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut) {
|
|||||||
if (!iconLoaded && fileassoc_me->icon_gfx && fileassoc_me->icon_gfx_small)
|
if (!iconLoaded && fileassoc_me->icon_gfx && fileassoc_me->icon_gfx_small)
|
||||||
iconLoaded = menuEntryImportIconGfx(me, fileassoc_me->icon_gfx, fileassoc_me->icon_gfx_small);
|
iconLoaded = menuEntryImportIconGfx(me, fileassoc_me->icon_gfx, fileassoc_me->icon_gfx_small);
|
||||||
|
|
||||||
|
//Attempt to load the nacp from {me->path filepath with extension .nacp}, then on failure use the config from fileassoc_me.
|
||||||
|
memset(tempbuf, 0, sizeof(tempbuf));
|
||||||
|
strncpy(tempbuf, me->path, sizeof(tempbuf));
|
||||||
|
tempbuf[sizeof(tempbuf)-1] = 0;
|
||||||
|
strptr = getExtension(tempbuf);
|
||||||
|
strncpy(strptr, ".nacp", sizeof(tempbuf)-1 - ((ptrdiff_t)strptr - (ptrdiff_t)tempbuf));
|
||||||
|
|
||||||
|
bool nacpLoaded = menuEntryLoadExternalNacp(me, tempbuf);
|
||||||
|
|
||||||
|
if (nacpLoaded) menuEntryParseNacp(me);
|
||||||
|
else {
|
||||||
strncpy(me->author, fileassoc_me->author, sizeof(me->author));
|
strncpy(me->author, fileassoc_me->author, sizeof(me->author));
|
||||||
me->author[sizeof(me->author)-1] = 0;
|
me->author[sizeof(me->author)-1] = 0;
|
||||||
|
|
||||||
strncpy(me->version, fileassoc_me->version, sizeof(me->version));
|
strncpy(me->version, fileassoc_me->version, sizeof(me->version));
|
||||||
me->version[sizeof(me->version)-1] = 0;
|
me->version[sizeof(me->version)-1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the argument data
|
// Initialize the argument data
|
||||||
argData_s* ad = &me->args;
|
argData_s* ad = &me->args;
|
||||||
|
Loading…
Reference in New Issue
Block a user