boot2: clean up pre-0.19.0 ams contents on upgrade

This commit is contained in:
Michael Scire 2021-03-21 04:12:30 -07:00 committed by SciresM
parent 79e4c82d7e
commit c8404e8452
5 changed files with 127 additions and 25 deletions

View file

@ -52,6 +52,26 @@ namespace ams::cfg {
return has_file;
}
Result DeleteFlagFile(const char *flag_path) {
/* We need the SD card to be available to delete anything. */
AMS_ABORT_UNLESS(IsSdCardInitialized());
/* Mount the sd card. */
char mount_name[fs::MountNameLengthMax + 1];
GetFlagMountName(mount_name);
R_TRY(fs::MountSdCard(mount_name));
ON_SCOPE_EXIT { fs::Unmount(mount_name); };
/* Get the flag path. */
char full_path[fs::EntryNameLengthMax + 1];
util::SNPrintf(full_path, sizeof(full_path), "%s:/%s", mount_name, flag_path[0] == '/' ? flag_path + 1 : flag_path);
/* Delete the file. */
R_TRY(fs::DeleteFile(full_path));
return ResultSuccess();
}
}
/* Flag utilities. */
@ -77,4 +97,10 @@ namespace ams::cfg {
return HasGlobalFlag(hbl_flag);
}
Result DeleteGlobalFlag(const char *flag) {
char global_flag[fs::EntryNameLengthMax + 1];
util::SNPrintf(global_flag, sizeof(global_flag) - 1, "/atmosphere/flags/%s.flag", flag);
return DeleteFlagFile(global_flag);
}
}