2020-09-20 01:21:28 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-09-26 15:55:24 +01:00
|
|
|
#include <switch.h>
|
2021-09-11 14:48:13 +01:00
|
|
|
|
2021-02-10 16:28:47 +00:00
|
|
|
#include <borealis.hpp>
|
2021-03-16 02:43:48 +00:00
|
|
|
#include <json.hpp>
|
2021-09-11 14:48:13 +01:00
|
|
|
#include <regex>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include "constants.hpp"
|
2020-09-20 01:21:28 +01:00
|
|
|
|
2021-03-16 02:04:21 +00:00
|
|
|
namespace util {
|
|
|
|
|
2021-03-16 14:56:46 +00:00
|
|
|
typedef char NsApplicationName[0x201];
|
|
|
|
typedef uint8_t NsApplicationIcon[0x20000];
|
2020-09-26 15:55:24 +01:00
|
|
|
|
2021-09-11 14:48:13 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2021-03-16 14:56:46 +00:00
|
|
|
uint64_t tid;
|
|
|
|
NsApplicationName name;
|
|
|
|
NsApplicationIcon icon;
|
|
|
|
brls::ListItem* listItem;
|
2021-06-27 23:46:00 +01:00
|
|
|
} app;
|
2020-09-26 15:55:24 +01:00
|
|
|
|
2021-03-16 14:56:46 +00:00
|
|
|
void clearConsole();
|
2021-09-11 14:48:13 +01:00
|
|
|
bool isArchive(const std::string& path);
|
2021-09-27 20:56:41 +01:00
|
|
|
void downloadArchive(const std::string& url, contentType type);
|
|
|
|
void downloadArchive(const std::string& url, contentType type, long& status_code);
|
2021-11-19 13:28:10 +00:00
|
|
|
void extractArchive(contentType type, const std::string& version = "");
|
2021-09-11 14:48:13 +01:00
|
|
|
std::string formatListItemTitle(const std::string& str, size_t maxScore = 140);
|
2021-03-16 14:56:46 +00:00
|
|
|
std::string formatApplicationId(u64 ApplicationId);
|
|
|
|
std::vector<std::string> fetchPayloads();
|
|
|
|
void shutDown(bool reboot = false);
|
2021-05-28 14:51:30 +01:00
|
|
|
void rebootToPayload(const std::string& path);
|
2022-03-30 21:23:15 +01:00
|
|
|
void showDialogBoxInfo(const std::string& text);
|
|
|
|
int showDialogBoxBlocking(const std::string& text, const std::string& opt);
|
|
|
|
int showDialogBoxBlocking(const std::string& text, const std::string& opt1, const std::string& opt2);
|
2021-05-22 17:10:34 +01:00
|
|
|
std::string getLatestTag(const std::string& url);
|
2021-06-27 23:46:00 +01:00
|
|
|
std::string downloadFileToString(const std::string& url);
|
2021-11-19 13:28:10 +00:00
|
|
|
std::string getCheatsVersion();
|
|
|
|
void saveToFile(const std::string& text, const std::string& path);
|
|
|
|
std::string readFile(const std::string& path);
|
2022-08-09 15:43:18 +01:00
|
|
|
std::string getAppPath();
|
2022-10-31 18:59:48 +00:00
|
|
|
void restartApp();
|
2021-03-16 14:56:46 +00:00
|
|
|
bool isErista();
|
2021-09-11 14:48:13 +01:00
|
|
|
void removeSysmodulesFlags(const std::string& directory);
|
2021-06-27 23:46:00 +01:00
|
|
|
std::string lowerCase(const std::string& str);
|
2021-06-28 15:58:04 +01:00
|
|
|
std::string upperCase(const std::string& str);
|
2021-06-27 23:46:00 +01:00
|
|
|
std::string getErrorMessage(long status_code);
|
|
|
|
bool isApplet();
|
2021-07-15 18:56:59 +01:00
|
|
|
std::string getContentsPath();
|
2022-10-31 18:59:48 +00:00
|
|
|
bool getBoolValue(const nlohmann::ordered_json& jsonFile, const std::string& key);
|
2021-09-15 16:50:34 +01:00
|
|
|
const nlohmann::ordered_json getValueFromKey(const nlohmann::ordered_json& jsonFile, const std::string& key);
|
2021-09-11 14:48:13 +01:00
|
|
|
} // namespace util
|