Awoo-Installer/source/nspInstall.cpp

79 lines
2.6 KiB
C++
Raw Normal View History

2019-10-22 22:14:37 +00:00
#include <cstring>
#include <sstream>
#include "install/install_nsp.hpp"
#include "nx/fs.hpp"
#include "util/file_util.hpp"
#include "util/title_util.hpp"
#include "util/error.hpp"
#include "nspInstall.hpp"
#include "ui/MainApplication.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
void setNspInfoText(std::string ourText){
mainApp->nspinstPage->pageInfoText->SetText(ourText);
mainApp->CallForRender();
}
void loadMainMenu(){
mainApp->LoadLayout(mainApp->mainPage);
}
}
namespace nspInstStuff {
FsStorageId m_destStorageId = FsStorageId_SdCard;
bool installNspFromFile(std::string ourNsp, int whereToInstall)
2019-10-22 22:14:37 +00:00
{
std::vector<std::string> installList;
installList.push_back(ourNsp);
if (whereToInstall) m_destStorageId = FsStorageId_NandUser;
2019-10-22 22:14:37 +00:00
for (unsigned int i = 0; i < installList.size(); i++)
{
std::string path = "@Sdcard://" + installList[i];
try
{
nx::fs::IFileSystem fileSystem;
fileSystem.OpenFileSystemWithId(path, FsFileSystemType_ApplicationPackage, 0);
tin::install::nsp::SimpleFileSystem simpleFS(fileSystem, "/", path + "/");
//last arg is ignore required firm version, read from config for this
tin::install::nsp::NSPInstallTask task(simpleFS, m_destStorageId, 1);
printf("NSP_INSTALL_PREPARING\n");
task.Prepare();
printf("Pre Install Records: \n");
//task.DebugPrintInstallData();
//std::stringstream ss;
//ss << translate(Translate::NSP_INSTALLING) << " " << tin::util::GetTitleName(task.GetTitleId(), task.GetContentMetaType()) << " (" << (i + 1) << "/" << installList.size() << ")";
//manager.m_printConsole->flags |= CONSOLE_COLOR_BOLD;
//tin::util::PrintTextCentred(ss.str());
//manager.m_printConsole->flags &= ~CONSOLE_COLOR_BOLD;
inst::ui::setNspInfoText("Installing " + ourNsp + "...");
2019-10-22 22:14:37 +00:00
task.Begin();
printf("Post Install Records: \n");
//task.DebugPrintInstallData();
}
catch (std::exception& e)
{
inst::ui::setNspInfoText("Failed to install NSP");
2019-10-22 22:14:37 +00:00
printf("NSP_INSTALL_FAILED\n");
printf("Failed to install NSP");
printf("%s", e.what());
fprintf(stdout, "%s", e.what());
return false;
2019-10-22 22:14:37 +00:00
}
}
printf("Done");
inst::ui::loadMainMenu();
return true;
2019-10-22 22:14:37 +00:00
}
}