mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-26 13:52:21 +00:00
pm: fix boot2 launch logic error
This commit is contained in:
parent
27ff119ba6
commit
8177a27db9
1 changed files with 26 additions and 17 deletions
|
@ -202,26 +202,35 @@ namespace sts::boot2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchFlaggedProgramsFromSdCard() {
|
void LaunchFlaggedProgramsFromSdCard() {
|
||||||
/* Allow for user-customizable programs. */
|
/* Validate that the titles directory exists. */
|
||||||
DIR *titles_dir = opendir("sdmc:/atmosphere/titles");
|
DIR *titles_dir = opendir("sdmc:/atmosphere/titles");
|
||||||
struct dirent *ent;
|
if (titles_dir == nullptr) {
|
||||||
if (titles_dir != nullptr) {
|
return;
|
||||||
ON_SCOPE_EXIT { closedir(titles_dir); };
|
}
|
||||||
|
ON_SCOPE_EXIT { closedir(titles_dir); };
|
||||||
|
|
||||||
while ((ent = readdir(titles_dir)) != nullptr) {
|
/* Iterate over entries in the titles directory */
|
||||||
if (strlen(ent->d_name) == 2 * sizeof(u64) && IsHexadecimal(ent->d_name)) {
|
struct dirent *ent;
|
||||||
ncm::TitleId title_id{strtoul(ent->d_name, nullptr, 16)};
|
while ((ent = readdir(titles_dir)) != nullptr) {
|
||||||
if (pm::info::HasLaunchedTitle(title_id)) {
|
/* Check that the subdirectory can be converted to a title id. */
|
||||||
return;
|
if (std::strlen(ent->d_name) == 2 * sizeof(ncm::TitleId) && IsHexadecimal(ent->d_name)) {
|
||||||
}
|
/* Check if we've already launched the title. */
|
||||||
char title_path[FS_MAX_PATH];
|
ncm::TitleId title_id{std::strtoul(ent->d_name, nullptr, 16)};
|
||||||
std::snprintf(title_path, sizeof(title_path), "sdmc:/atmosphere/titles/%s/flags/boot2.flag", ent->d_name);
|
if (pm::info::HasLaunchedTitle(title_id)) {
|
||||||
FILE *f_flag = fopen(title_path, "rb");
|
continue;
|
||||||
if (f_flag != nullptr) {
|
|
||||||
fclose(f_flag);
|
|
||||||
LaunchTitle(nullptr, ncm::TitleLocation::Make(title_id, ncm::StorageId::None), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if the title is flagged. */
|
||||||
|
char title_path[FS_MAX_PATH];
|
||||||
|
std::snprintf(title_path, sizeof(title_path), "sdmc:/atmosphere/titles/%s/flags/boot2.flag", ent->d_name);
|
||||||
|
FILE *f_flag = fopen(title_path, "rb");
|
||||||
|
if (f_flag == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fclose(f_flag);
|
||||||
|
|
||||||
|
/* Actually launch the title. */
|
||||||
|
LaunchTitle(nullptr, ncm::TitleLocation::Make(title_id, ncm::StorageId::None), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue