2021-01-02 23:22:45 +00:00
|
|
|
//#include <stdio.h>
|
|
|
|
//#include <stdlib.h>
|
2020-09-20 01:21:28 +01:00
|
|
|
#include <string>
|
|
|
|
#include <switch.h>
|
|
|
|
|
|
|
|
#include <borealis.hpp>
|
|
|
|
|
|
|
|
#include "main_frame.hpp"
|
|
|
|
#include "constants.hpp"
|
|
|
|
#include "utils.hpp"
|
2020-10-05 23:53:12 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-01-02 23:22:45 +00:00
|
|
|
//#include <string.h>
|
|
|
|
//#include <stdio.h>
|
2020-09-20 01:21:28 +01:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <unistd.h>
|
2020-10-05 01:59:46 +01:00
|
|
|
#include <dirent.h>
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2020-10-05 01:59:46 +01:00
|
|
|
#include <sstream>
|
2021-01-02 23:22:45 +00:00
|
|
|
#include <fstream>
|
2020-10-05 23:53:12 +01:00
|
|
|
|
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
|
|
|
|
2021-01-02 23:22:45 +00:00
|
|
|
//TimeServiceType __nx_time_service_type = TimeServiceType_System;
|
2020-12-27 17:11:40 +00:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
// Init the app
|
|
|
|
if (!brls::Application::init(APP_TITLE))
|
|
|
|
{
|
|
|
|
brls::Logger::error("Unable to init Borealis application");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2020-10-05 23:53:12 +01:00
|
|
|
i18n::loadTranslations();
|
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
// Setup verbose logging on PC
|
|
|
|
#ifndef __SWITCH__
|
|
|
|
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Initialize services with a PC shim
|
2020-10-05 01:59:46 +01:00
|
|
|
setsysInitialize();
|
|
|
|
plInitialize(PlServiceType_User);
|
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
nsInitialize();
|
|
|
|
socketInitializeDefault();
|
|
|
|
nxlinkStdio();
|
|
|
|
|
2020-09-20 21:58:40 +01:00
|
|
|
splInitialize();
|
2020-10-07 01:08:39 +01:00
|
|
|
|
|
|
|
romfsInit();
|
2020-09-20 01:21:28 +01:00
|
|
|
createTree(CONFIG_PATH);
|
|
|
|
|
2020-10-07 01:08:39 +01:00
|
|
|
std::string appName = std::string(argv[0]).substr(5);
|
|
|
|
bool star = false;
|
|
|
|
//if(1){
|
|
|
|
if(appName.find(APP_PATH) != std::string::npos){
|
|
|
|
for(auto& p : std::filesystem::directory_iterator(APP_PATH)){
|
|
|
|
if(p.path().extension().string() == ".nro" && p.path().string() != appName){
|
|
|
|
std::cout << p.path().string() << std::endl;
|
|
|
|
std::filesystem::remove(p.path());
|
|
|
|
}
|
|
|
|
if(p.path().extension().string() == ".star"){
|
|
|
|
std::filesystem::remove(p.path());
|
|
|
|
star = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(star) {
|
|
|
|
std::ofstream starFile(std::string(APP_PATH) + ".aio-switch-updater-v" + APP_VERSION + ".nro.star", std::ofstream::out);
|
|
|
|
}
|
2020-10-05 23:53:12 +01:00
|
|
|
|
2020-09-20 01:21:28 +01:00
|
|
|
brls::Logger::setLogLevel(brls::LogLevel::DEBUG);
|
|
|
|
brls::Logger::debug("Start");
|
|
|
|
|
|
|
|
// Create root view
|
|
|
|
MainFrame *mainFrame = new MainFrame();
|
|
|
|
|
|
|
|
// Add the root view to the stack
|
|
|
|
brls::Application::pushView(mainFrame);
|
|
|
|
|
|
|
|
// Run the app
|
|
|
|
while (brls::Application::mainLoop());
|
|
|
|
|
|
|
|
// Exit
|
2020-10-09 21:27:18 +01:00
|
|
|
romfsExit();
|
2020-09-20 01:21:28 +01:00
|
|
|
splExit();
|
|
|
|
socketExit();
|
|
|
|
nsExit();
|
2020-10-05 01:59:46 +01:00
|
|
|
setsysExit();
|
|
|
|
plExit();
|
2020-09-20 01:21:28 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|