mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
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:
parent
0ad0dc18bc
commit
66f5b8ec57
@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION "v1.0"
|
||||
#define VERSION "v1.3"
|
||||
|
||||
#endif // VERSION_H
|
||||
|
||||
@ -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
1
nitrofiles/installer.ver
Normal file
@ -0,0 +1 @@
|
||||
v1.3
|
||||
Loading…
Reference in New Issue
Block a user