Try both ntrboot.nds and boot.nds when loading nitrofs

Bundle an installer.ver file in the nitrofiles so that it can be matched against the current version of the installer to ensure it's the right file being loaded
This commit is contained in:
Edoardo Lolletti 2025-08-21 17:40:19 +02:00
parent 0ad0dc18bc
commit 66f5b8ec57
3 changed files with 31 additions and 16 deletions

View File

@ -1,6 +1,6 @@
#ifndef VERSION_H
#define VERSION_H
#define VERSION "v1.0"
#define VERSION "v1.3"
#endif // VERSION_H

View File

@ -3,6 +3,7 @@
#include <format>
#include <exception>
#include <memory>
#include <vector>
#include "bgMenu.h"
#include "consoleInfo.h"
@ -273,6 +274,33 @@ void checkStage2Supported() {
exit(0);
}
std::vector<std::string_view> getInstallerPaths(int argc, char **argv) {
if(argc > 0)
return {std::string_view{argv[0]}};
DeviceList* deviceList = getDeviceList();
if(deviceList) return {std::string_view{ deviceList->appname}};
return {"sd:/ntrboot.nds", "sd:/boot.nds"};
}
void setupNitrofs(int argc, char **argv) {
for(const auto& path : getInstallerPaths(argc, argv)){
if(!nitroFSInit(path.data()))
continue;
auto* file = fopen("nitro:/installer.ver", "rb");
if(!file)
continue;
char verstring[10]{};
fread(verstring, 1, sizeof(verstring) - 1, file);
fclose(file);
if(std::string_view{verstring} == VERSION)
return;
}
messageBox("nitroFSInit()...\x1B[31mFailed\n\x1B[47m");
exit(0);
}
void checkNocashFooter(consoleInfo& info) {
NocashFooter footer;
@ -324,16 +352,6 @@ void waitForBatteryChargedEnough() {
}
}
const char* getInstallerPath(int argc, char **argv) {
if(argc > 0)
return argv[0];
DeviceList* deviceList = getDeviceList();
if(deviceList) return deviceList->appname;
return "sd:/ntrboot.nds";
}
void loadUnlaunchInstaller() {
if (fileExists("sd:/unlaunch.dsi"))
{
@ -688,11 +706,7 @@ int main(int argc, char **argv)
{
setup();
checkStage2Supported();
if (!nitroFSInit(getInstallerPath(argc, argv)))
{
messageBox("nitroFSInit()...\x1B[31mFailed\n\x1B[47m");
}
setupNitrofs(argc, argv);
loadUnlaunchInstaller();

1
nitrofiles/installer.ver Normal file
View File

@ -0,0 +1 @@
v1.3