MCPcopy Create free account
hub / github.com/devkitPro/3ds-hbmenu / menuEntryLoad

Function menuEntryLoad

source/menu-entry.c:304–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304bool menuEntryLoad(menuEntry_s* me, const char* name, bool shortcut)
305{
306 static char tempbuf[PATH_MAX+1];
307 bool isAppBundleFolder = false;
308
309 menu_s* menuFileAssoc = menuFileAssocGetCurrent();
310 menuEntry_s* fileAssocEntry = NULL;
311
312 tempbuf[PATH_MAX] = 0;
313 strcpy(me->name, name);
314 snprintf(me->starpath, sizeof(me->starpath)-1, "%.*s.star", sizeof(me->starpath)-12, me->path);
315
316 if (me->type == ENTRY_TYPE_FOLDER) do
317 {
318 // Check if this folder is an application bundle (except if it's the starting directory)
319 if (strcmp(me->path, "sdmc:/3ds") == 0)
320 break;
321
322 snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s/boot.3dsx", sizeof(tempbuf)-12, me->path);
323 bool found = fileExists(tempbuf);
324 bool fileAssocFlag = false;
325
326 if (!found)
327 {
328 snprintf(tempbuf, sizeof(tempbuf)-1, "%.*s/%.*s.3dsx", sizeof(tempbuf)/2, me->path, sizeof(tempbuf)/2-7, name);
329 found = fileExists(tempbuf);
330 }
331
332 if (!found && menuFileAssoc->nEntries > 0) {
333 fileAssocFlag = true;
334
335 DIR* dir = opendir(fileAssocEntry->path);
336 struct dirent* dp;
337
338 if (dir) {
339 int index = 0;
340 while ((dp = readdir(dir))) {
341 if (dp->d_name[0] == '.')
342 continue;
343
344 for (fileAssocEntry = menuFileAssoc->firstEntry, index = 0; fileAssocEntry; fileAssocEntry = fileAssocEntry->next, index++) {
345 if (!fileAssocEntry->fileAssocType)
346 continue;
347
348 if (strcmp(dp->d_name, fileAssocEntry->fileAssocStr))
349 continue;
350
351 snprintf(tempbuf, sizeof(tempbuf) - 1, "%.*s/%.*s", (int)sizeof(tempbuf) / 2, me->path, (int)sizeof(tempbuf) / 2 - 7, dp->d_name);
352 found = fileExists(tempbuf);
353
354 if (found)
355 break;
356 }
357 }
358 closedir(dir);
359 }
360 }
361

Callers 2

menuScanFunction · 0.85
menuEntryFileAssocLoadFunction · 0.85

Calls 15

menuFileAssocGetCurrentFunction · 0.85
fileExistsFunction · 0.85
textGetStringFunction · 0.85
shortcutCreateFunction · 0.85
shortcutFreeFunction · 0.85
getExtensionFunction · 0.85
getSlashFunction · 0.85
menuEntryParseSmdhFunction · 0.85
loaderCanUseTitlesFunction · 0.85
fixSpaceNewLineFunction · 0.85

Tested by

no test coverage detected