stat(path) before trying to launch a nro (#129)

This commit is contained in:
HamletDuFromage 2021-06-09 09:16:37 +02:00 committed by GitHub
parent 95411fe5e9
commit aef37e10f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -133,6 +133,12 @@ const char* const g_strings[StrId_Max][17] =
STR_ZH_HANT("開啓檔案失敗:\n%s"),
},
[StrId_NroNotFound] =
{
STR_EN("Could not find executable: %s"),
STR_FR("Impossible trouver l'exécutable : %s"),
},
[StrId_NoAppsFound_Title] =
{
STR_EN("No applications found"),

View File

@ -11,6 +11,7 @@ typedef enum
StrId_DefaultPublisher,
StrId_IOError,
StrId_CouldNotOpenFile,
StrId_NroNotFound,
StrId_NoAppsFound_Title,
StrId_NoAppsFound_Msg,

View File

@ -68,15 +68,26 @@ static void launchFile(const char* path, argData_s* args)
init_args(argBuf, sizeof(argBuf)-1, args->buf, sizeof(args->buf));
Result rc = envSetNextLoad(path, argBuf);
if(R_FAILED(rc)) {
struct stat st;
if (stat(path, &st) == -1) {
memset(msg, 0, sizeof(msg));
snprintf(msg, sizeof(msg)-1, "%s\n2%03d-%04d", textGetString(StrId_AppLaunchError), R_MODULE(rc), R_DESCRIPTION(rc));
snprintf(msg, sizeof(msg)-1, textGetString(StrId_NroNotFound), path);
menuCreateMsgBox(780, 300, msg);
menuScan(".");
}
else {
uiExitLoop();
Result rc = envSetNextLoad(path, argBuf);
if(R_FAILED(rc)) {
memset(msg, 0, sizeof(msg));
snprintf(msg, sizeof(msg)-1, "%s\n2%03d-%04d", textGetString(StrId_AppLaunchError), R_MODULE(rc), R_DESCRIPTION(rc));
menuCreateMsgBox(780, 300, msg);
}
else {
uiExitLoop();
}
}
}