TegraScript/scripts/systemwipe.te
suchmememanyskill b4c300f315
Rewrite (#4)
* Initial TScript v2 commit

* Fix || issue

* another formatting issue

* small spelling fixes

* destenationexplorer intensifies

* write fwDump.te

* add timer to fwdump

* add old stuff back

Co-authored-by: suchmememanyskill <suchmememanyskill@users.noreply.github.com>
2021-01-05 16:55:48 +01:00

122 lines
No EOL
2.1 KiB
Text

checkIfImportantSave = {
importantSaves = ["8000000000000120", "80000000000000d1", "8000000000000047"]
j = 0
important = 0
while (j < len(importantSaves)){
if (importantSaves[j] == save){
important = 1
}
j = j + 1
}
}
ver = version()
println("Tegrascript system wiper")
println("Running on TE ", ver)
println()
BTN_X = 0x2
if (_EMU) {
menuOptions = ["Exit", "Sysmmc", "Emummc"]
}
else() {
menuOptions = ["Exit", "Sysmmc"]
}
print("Wipe from: ")
res = menu(menuOptions, 0)
clearscreen()
if (res == 0){
exit()
}
if (res == 1){
println("Mounting Sysmmc")
mount = mmcConnect("SYSMMC")
}
if (res == 2){
println("Mounting Emummc")
mount = mmcConnect("EMUMMC")
}
if (mount){
println("Error connecting mmc!")
pause()
exit()
}
if (mmcMount("SYSTEM")) {
println("Failed to mount SYSTEM")
pause()
exit()
}
color("RED")
println("Are you sure you want to wipe everything?\nThis includes:\n- Saves\n- Game Data\n- All other data on the system\n\nUse this only as a last resort!")
color("YELLOW")
wait(10000)
println("Press X to continue\nPress any other button to exit")
start = pause() & BTN_X
if (!start){
color("WHITE")
exit()
}
color("WHITE")
println("Deleting SYSTEM saves")
files = dirRead("bis:/save")
i = 0
color("RED")
while (i < len(files)) {
if (!fileProperties[i]){ # checks if it's not a file
save = files[i]
checkIfImportantSave()
if (!important){
print("\rDeleting ", save)
res = fileDel(pathCombine("bis:/save", save))
if (res) {
println("\nFile deletion failed!")
pause()
exit()
}
}
}
i = i + 1
}
color("WHITE")
println("\n\nDeleting USER\n")
color("RED")
if (mmcMount("USER")){
println("Failed to mount USER")
pause()
exit()
}
toDel = ["Album", "Contents", "save", "saveMeta", "temp"]
i = 0
while (i < len(toDel)){
dirDel(pathCombine("bis:/", toDel[i]))
mkdir(pathCombine("bis:/", toDel[i]))
i = i + 1
}
mkdir("bis:/Contents/placehld")
mkdir("bis:/Contents/registered")
color("GREEN")
println("\n\nDone!")
pause()